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, java.lang.String frequency, java.lang.String scope)returns an appropriately camel-cased String
that is a candidate class name for a builder
if persistenceType is "memory" or "file" this returns
the correct class name and package name for these classes
i.e. com.iplanet.ias.web
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("memory")
| 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));
if(frequency != null) {
sb.append(camelCase(frequency));
}
if(scope != null) {
sb.append(camelCase(scope));
}
sb.append("StrategyBuilder");
String classname = sb.toString();
return classname;
|
PersistenceStrategyBuilder | createPersistenceStrategyBuilder(java.lang.String persistenceType, java.lang.String frequency, java.lang.String scope, org.apache.catalina.Context ctx)creates the correct implementation of PersistenceStrategyBuilder
if an invalid combination is input; an error is logged
and MemoryStrategyBuilder is returned
String resolvedPersistenceFrequency = null;
String resolvedPersistenceScope = null;
PersistenceTypeResolver persistenceTypeResolver
= this.getPersistenceTypeResolver();
String resolvedPersistenceType
= persistenceTypeResolver.resolvePersistenceType(persistenceType);
//System.out.println("resolvedPersistenceType = " + resolvedPersistenceType);
//this is only for my testing -do not check this in this way
/*
if(resolvedPersistenceType.equalsIgnoreCase("ha")) {
resolvedPersistenceType = "replicated";
}
System.out.println("temp resolvedPersistenceType = " + resolvedPersistenceType);
*/
//end of temp testing part remove before checking in
if( resolvedPersistenceType.equalsIgnoreCase("memory")
| resolvedPersistenceType.equalsIgnoreCase("file")) {
//deliberately leaving frequency & scope null
} else {
resolvedPersistenceFrequency = frequency;
resolvedPersistenceScope = scope;
}
_logger.finest("resolvedPersistenceType = " + resolvedPersistenceType);
_logger.finest("resolvedPersistenceFrequency = " + resolvedPersistenceFrequency);
_logger.finest("resolvedPersistenceScope = " + resolvedPersistenceScope);
//testPersistenceTypeResolver();
String passedInPersistenceType = persistenceType;
PersistenceStrategyBuilder builder = new MemoryStrategyBuilder();
//String className = createClassNameFrom(persistenceType, frequency, scope);
String className = createClassNameFrom(resolvedPersistenceType, resolvedPersistenceFrequency, resolvedPersistenceScope);
//begin temp code for testing
// for testing - remove after testing complete
/*
if(persistenceType.equalsIgnoreCase("ha")) {
passedInPersistenceType = "replicated";
className = "com.sun.enterprise.ee.web.initialization.ReplicatedWebmethodSessionStrategyBuilder";
}
*/
//System.out.println("ctx: " + ctx.getName() + "passed in persistenceType: " + persistenceType);
//end temp code for testing
_logger.finest("PersistenceStrategyBuilderFactory>>createPersistenceStrategyBuilder: "
+ "CandidateBuilderClassName = " + className);
try {
builder =
(PersistenceStrategyBuilder) (Class.forName(className)).newInstance();
} catch (Exception ex) {
Object[] params = { getApplicationId(ctx), persistenceType, frequency, scope };
_logger.log(Level.WARNING,
"webcontainer.invalidSessionManagerConfig",
params);
}
builder.setPersistenceFrequency(frequency);
builder.setPersistenceScope(scope);
//FIXME change later
builder.setPassedInPersistenceType(passedInPersistenceType);
//builder.setPassedInPersistenceType(persistenceType);
return builder;
|
PersistenceStrategyBuilder | createPersistenceStrategyBuilder(java.lang.String persistenceType, java.lang.String frequency, java.lang.String scope)creates the correct implementation of PersistenceStrategyBuilder
if an invalid combination is input; an error is logged
and MemoryStrategyBuilder is returned
String passedInPersistenceType = persistenceType;
PersistenceStrategyBuilder builder = new MemoryStrategyBuilder();
String className = createClassNameFrom(persistenceType, frequency, scope);
_logger.finest("PersistenceStrategyBuilderFactory>>createPersistenceStrategyBuilder: "
+ "CandidateBuilderClassName = " + className);
try {
builder =
(PersistenceStrategyBuilder) (Class.forName(className)).newInstance();
} catch (Exception ex) {
Object[] params = { persistenceType, frequency, scope };
_logger.log(Level.WARNING,
"webcontainer.invalidSessionManagerConfig",
params);
}
builder.setPersistenceFrequency(frequency);
builder.setPersistenceScope(scope);
//FIXME change later
builder.setPassedInPersistenceType(passedInPersistenceType);
//builder.setPassedInPersistenceType(persistenceType);
return builder;
|
public java.lang.String | getApplicationId(org.apache.catalina.Context ctx)returns the application id for the module
com.sun.enterprise.web.WebModule wm =
(com.sun.enterprise.web.WebModule)ctx;
return wm.getID();
|
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
if(_eeBuilderPath == null) {
ServerConfigLookup lookup = new ServerConfigLookup();
_eeBuilderPath = lookup.getEEBuilderPathFromConfig();
}
_logger.finest("_eeBuilderPath = " + _eeBuilderPath);
return _eeBuilderPath;
|
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) {
_logger.finest("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();
|
public PersistenceStrategyBuilder | testCreatePersistenceStategyBuilder(java.lang.String persistenceType, java.lang.String frequency, java.lang.String scope)
return this.createPersistenceStrategyBuilder(persistenceType, frequency, scope);
|
private void | testPersistenceTypeResolver()
PersistenceTypeResolver persistenceTypeResolver
= this.getPersistenceTypeResolver();
List testTypes = Arrays.asList("memory", "file", "ha", "replicated", "registered_foo", "non-registered_foo");
for(int i=0; i<testTypes.size(); i++) {
String nextType = (String)testTypes.get(i);
String nextResolvedPersistenceType
= persistenceTypeResolver.resolvePersistenceType(nextType);
System.out.println("nextType=" + nextType + "::nextResolvedPersistenceType = " + nextResolvedPersistenceType + "\n");
}
|