|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpu.patterns.factory.PropertyFactoryConfigStrategy
Implementation of IPrototypeFactory.IConfigStrategy for property-file-based configuration.
A prototype list should comply with the following syntax:
<protolist> = [<protospec>{;<protospec>}*]
<protospec> = [<name1>[,<name2>[,<name3>[,<nameN>]]]=<classname>]
where <name1> ... <nameN> are the names under which the prototype is keyed and <classname> is the
full name of the prototype implementation class, or of the IPrototypeFactory.IInstantiator to which
instantiation should be delegated. Every class listed must have an accessible no-arg constructor.
The source of the <protospec> is by default a System property named "<factoryClassName>.prototypes" where <factoryClassName> is the full class name of the factory being configured; but in the vast majority of cases the subclass will override the following method
protected String fetchPrototypeSpec();
and have it return the <protospec> from whichever configuration source the application employs.
To specify a delimeter to use instead of ";", override the following method:
protected String getPrototypeDeclarationSeparator();
| Constructor Summary | |
protected |
PropertyFactoryConfigStrategy(IPrototypeFactory fact)
|
| Method Summary | |
protected java.lang.Object |
classNameToInstance(java.lang.String className)
Returns a new instance of the prototype whose name is passed. |
void |
configure()
|
protected java.lang.String |
fetchPrototypeSpec()
This method fetches the factory's prototype list from the configuration source. |
protected java.lang.String |
getAssignmentString()
Returns the string that acts as a separator between the list of prototype names and the name of the prototype class. |
IPrototypeFactory |
getFactory()
|
protected java.lang.String |
getFallbackPrototypeSpec()
Returns the prototype spec that is used if none is found in the configuration database. |
protected java.lang.String |
getPrototypeDeclarationSeparator()
Returns the string that acts as a separator between <protospec>'s. |
protected java.lang.String |
getPrototypeNameSeparator()
Returns the string that acts as a separator between successive prototype names. |
protected java.lang.String |
getPrototypeSpec()
|
protected boolean |
logErrorIfConfigurationUnavailable()
Returns whether an error is logged if the default configuration value is unavailable and the fallback is used in its place. |
protected void |
processOneConfigProtoDef(java.lang.String protoDef)
Processes a single prototype declaration. |
void |
reconfigureIfNecessary()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected PropertyFactoryConfigStrategy(IPrototypeFactory fact)
| Method Detail |
public IPrototypeFactory getFactory()
getFactory in interface IPrototypeFactory.IConfigStrategypublic void reconfigureIfNecessary()
reconfigureIfNecessary in interface IPrototypeFactory.IConfigStrategypublic void configure()
configure in interface IPrototypeFactory.IConfigStrategyprotected boolean logErrorIfConfigurationUnavailable()
true, but subclasses are free to override.
true if an error should be logged, false otherwise.protected java.lang.String getFallbackPrototypeSpec()
null, but
subclasses are free to override.
null by default).protected java.lang.String getPrototypeDeclarationSeparator()
protected java.lang.String getPrototypeNameSeparator()
protected java.lang.String getAssignmentString()
protected void processOneConfigProtoDef(java.lang.String protoDef)
protected java.lang.Object classNameToInstance(java.lang.String className)
throws java.lang.Throwable
Thread.currentThread().getContextClassLoader().loadClass(className).newInstance()", but
subclasses are free to override.
java.lang.Throwableprotected java.lang.String getPrototypeSpec()
protected java.lang.String fetchPrototypeSpec()
return System.getProperty( getFactory().getClass().getName() + ".prototypes", "" );
However, in the majority of cases the subclass will override this to hook into whichever configuration source the application uses.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||