FileDocCategorySizeDatePackage
SFSBTxStoreManagerFactory.javaAPI DocGlassfish v2 API6859Fri May 04 22:32:56 BST 2007com.sun.ejb.base.sfsb.initialization

SFSBTxStoreManagerFactory

public class SFSBTxStoreManagerFactory extends Object
Factory for creating SFSBTxStoreManager. SFSBTxStoreManager is responsible for checkpointing an Array of SFSBBeanState(s) (as a single transactional unit if possible)
author
Mahesh Kannan

Fields Summary
private static final Logger
_logger
protected static final String
DEFAULT_EE_PACKAGE
Constructors Summary
Methods Summary
private static java.lang.StringcamelCase(java.lang.String inputString)
this method strips out all non-alpha characters; camelCases the result

param
inputString

        String strippedString = stripNonAlphas(inputString);
        String firstLetter = (strippedString.substring(0, 1)).toUpperCase();
        String remainingPart = 
            (strippedString.substring(1, strippedString.length())).toLowerCase();
        return firstLetter + remainingPart;
    
private static java.lang.StringcreateClassNameFrom(java.lang.String persistenceType)

param
persistenceType

        StringBuffer sbuf = new StringBuffer();
	sbuf.append(getEEPackage()).append(".") 
	    .append(camelCase(persistenceType))
	    .append("TxStoreManager");
        String classname = sbuf.toString();
        return classname;
    
public static com.sun.ejb.spi.sfsb.store.SFSBTxStoreManagercreateSFSBTxStoreManager(java.lang.String persistenceType)

        
    
       
	     
    
	if ("file".equalsIgnoreCase(persistenceType)) {
	    return new FileTxStoreManager();
	}
        String resolvedPersistenceType 
            = getResolvedPersistenceType(persistenceType);
        Exception exception = null;
	try {
	    String className = createClassNameFrom(resolvedPersistenceType);
	    return (SFSBTxStoreManager)
		    (Class.forName(className)).newInstance();
	} catch (ClassNotFoundException cnfEx) {
            exception = cnfEx;
	    _logger.log(Level.FINE,
		"Exception while creating SFSBTxStoreManager for persistence "
		+ "type: " + persistenceType + ". Exception: " + cnfEx);
	} catch (Exception ex) {
            exception = ex;
	    _logger.log(Level.FINE,
		"Exception while creating SFSBTxStoreManager for "
		+ "persistence type: " + persistenceType, ex);
	}

        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, "Created FileTxStoreManager for persistence"
                    + " type: " + persistenceType, exception);
        }

	return new FileTxStoreManager();
    
private static java.lang.StringgetEEPackage()
return the path where the ee builders reside although this method allows this to be configurable via an property in server.xml we do not expose it and it should not be re-configured

        return DEFAULT_EE_PACKAGE;
    
private static java.lang.StringgetResolvedPersistenceType(java.lang.String persistenceType)

        String resolverClassName 
            = "com.sun.enterprise.ee.web.sessmgmt.EEPersistenceTypeResolver";
    
        String resolvedPersistenceType = persistenceType;
        PersistenceTypeResolver persistenceTypeResolver = null;
        try {
            persistenceTypeResolver = 
                (PersistenceTypeResolver) (Class.forName(resolverClassName)).newInstance();
            if(persistenceTypeResolver != null) {
                resolvedPersistenceType 
                    = persistenceTypeResolver.resolvePersistenceType(persistenceType);
                //this is because file not memory is the correct 'default'
                if("memory".equalsIgnoreCase(resolvedPersistenceType)) {
                    resolvedPersistenceType = "file";        
                } else if("replicated".equalsIgnoreCase(resolvedPersistenceType)) {
                    //this is because replicated can make use of the same
                    //HaTxStoreManager that ha uses
                    resolvedPersistenceType = "ha";        
                }
            }
        } catch (Exception ex) {
            _logger.log(Level.WARNING, "unable to create persistence type resolver");
        }         
        return resolvedPersistenceType;
    
private static java.lang.StringstripNonAlphas(java.lang.String inputString)
this method strips out all non-alpha characters

param
inputString

        StringBuffer sb = new StringBuffer(50);
        for(int i=0; i<inputString.length(); i++) {
            char nextChar = inputString.charAt(i);
            if(Character.isLetter(nextChar)) {
                sb.append(nextChar);
            }
        }
        return sb.toString();