Methods Summary |
---|
private java.lang.String | camelCase(java.lang.String inputString)this method strips out all non-alpha characters; camelCases the result
String strippedString = stripNonAlphas(inputString);
String firstLetter = (strippedString.substring(0, 1)).toUpperCase();
String remainingPart =
(strippedString.substring(1, strippedString.length())).toLowerCase();
return firstLetter + remainingPart;
|
private java.lang.String | createClassNameFrom(java.lang.String persistenceType)returns an appropriately camel-cased String
that is a candidate class name for a builder
if persistenceType is "file" this returns
the correct class name and package name for these classes
i.e. com.sun.ejb.spi.??
FIXME:figure this out where the file builder
will reside
otherwise they are in com.sun.appserv.ee.web.initialization
StringBuffer sb = new StringBuffer();
//using package name will mean this will work
//even if class is moved to another package
String pkg = this.getClass().getPackage().getName();
if( !(persistenceType.equalsIgnoreCase("file")) )
{
//pkg is the package where EE builders MUST reside
//this defaults to
//"com.sun.enterprise.ee.web.initialization"
// but is configurable via (not-well-publicized)
//property in server.xml
//at "/server/availability-service/persistence-store/property[@name='ee-builder-path']"
pkg = this.getEEBuilderPath();
}
sb.append(pkg + ".");
sb.append(camelCase(persistenceType));
sb.append("StrategyBuilder");
String classname = sb.toString();
return classname;
|
public com.sun.ejb.spi.sfsb.initialization.PersistenceStrategyBuilder | createPersistenceStrategyBuilder(java.lang.String persistenceType)creates the correct implementation of PersistenceStrategyBuilder
if an invalid combination is input; an error is logged
and MemoryStrategyBuilder is returned
/* FIXME replace after testing
PersistenceTypeResolver persistenceTypeResolver
= this.getPersistenceTypeResolver();
String resolvedPersistenceType
= persistenceTypeResolver.resolvePersistenceType(persistenceType);
debug("resolvedPersistenceType = " + resolvedPersistenceType);
*/
String passedInPersistenceType = persistenceType;
PersistenceStrategyBuilder builder = new FileStrategyBuilder();
String className = createClassNameFrom(persistenceType);
if(_logger.isLoggable(Level.FINEST)) {
_logger.finest("PersistenceStrategyBuilderFactory>>createPersistenceStrategyBuilder: "
+ "CandidateBuilderClassName = " + className);
}
boolean requestedBuilderCreated = false;
try {
builder =
(PersistenceStrategyBuilder) (Class.forName(className)).newInstance();
requestedBuilderCreated = true;
} catch (ClassNotFoundException clnfEx) {
_logger.log(Level.WARNING, "Couldn't find class: "
+ className + " for persistenceType: "
+ persistenceType);
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Exception while creating Builder", clnfEx);
}
} catch (Exception ex) {
_logger.log(Level.WARNING, "Exception while creating Builder", ex);
}
if (! requestedBuilderCreated) {
_logger.log(Level.WARNING, "Couldn't create builder for "
+ "persistence type: " + persistenceType
+". Instead created FileStrategyBuilder....");
}
builder.setPassedInPersistenceType(passedInPersistenceType);
return builder;
|
private static void | debug(java.lang.String s)
|
private java.lang.String | getEEBuilderPath()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_BUILDER_PATH;
|
private PersistenceTypeResolver | getPersistenceTypeResolver()
String resolverClassName
= "com.sun.enterprise.ee.web.sessmgmt.EEPersistenceTypeResolver";
PersistenceTypeResolver persistenceTypeResolver = null;
try {
persistenceTypeResolver =
(PersistenceTypeResolver) (Class.forName(resolverClassName)).newInstance();
} catch (Exception ex) {
debug("unable to create persistence type resolver");
}
return persistenceTypeResolver;
|
private java.lang.String | stripNonAlphas(java.lang.String inputString)this method strips out all non-alpha characters
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();
|