|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.backsource.utils.lang.Factory
A baseclass or helper to make it easier to create factories following the JAXP pattern; but with more configuration options.
The normal pattern is to have an abstract factory through which an implementing factory is obtainable through the newInstance() method. The implementing factory then has a method implementation to get the class the factory is meant to be able to produce. This class helps in defining the behaviour that is used by the abstract factory to lookup the implementing factory.
Factories that uses this class to implement its factory handling must either inherit from this class or demand that the implementing factories have default constructors with public access.
| Constructor Summary | |
Factory()
|
|
| Method Summary | |
static java.lang.Object |
findInstance(java.lang.String key,
java.util.Properties env,
java.lang.String defaultClass,
boolean reverseOrder)
Find and instantiate an implementing factory. |
static java.lang.String |
getProperty(java.lang.String prop)
The property is not null only if it is not null, and has a length of > 0 after its been trimed; |
static java.lang.String |
jarService(java.lang.ClassLoader cl,
java.lang.String key,
boolean reverseOrder)
Lookup the resource META-INF/services/key where key is the name of the property file to look for. |
static java.lang.String |
jarService(java.lang.String key,
boolean reverseOrder)
Lookup the resource META-INF/services/key where key is the name of the property file to look for. |
static java.util.List |
list(java.util.Enumeration e)
Implement the jdk 1.4.1 Collection list behaviour. |
static java.lang.Object |
newInstance(java.lang.String className)
Load the given classname from the thread context classloader, or Class.forName if no context loader was found. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Factory()
| Method Detail |
public static java.lang.Object findInstance(java.lang.String key,
java.util.Properties env,
java.lang.String defaultClass,
boolean reverseOrder)
throws java.lang.ClassNotFoundException
The reverse order mechanism makes it possible to specify component specific factory configurations in environments which deploys components int their owne classloader.
key - the property name of the factory; the normal pattern is to use the fully qualified classname of the abstract factory.env - a possibly null Properties that contains a locally given value for key.defaultClass - the default class to load if no configuration is found.reverseOrder - in reverse order the service API will be used before any System properties are checked; and the resource file will be searched in leaf class loader order first.
java.lang.ClassNotFoundException - if not default or property was found to create the factory or if the configured factory was not available in the classpath.
java.lang.IllegalArgumentException - thrown if key is null.
java.lang.IllegalStateException - if no configuration was found and defaultClass was also null.public static java.lang.String getProperty(java.lang.String prop)
public static java.lang.Object newInstance(java.lang.String className)
throws java.lang.ClassNotFoundException
className - the fully qualified name of the class to load.
java.lang.ClassNotFoundException - if it was not possible to load the given class or if it was null.
public static java.lang.String jarService(java.lang.String key,
boolean reverseOrder)
The context classloader is searched first and if the service property was not found the classloader of this class is used.
key - the name of the resource/property.reverseOrder - if true return the last resource in the enumeration returned by getResource.
public static java.lang.String jarService(java.lang.ClassLoader cl,
java.lang.String key,
boolean reverseOrder)
cl - the classloader to use to lookup the resource.key - the name of the resource/property.reverseOrder - if true return the last resource in the enumeration returned by getResource.
public static java.util.List list(java.util.Enumeration e)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||