|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.yajul.util.ObjectFactory
public class ObjectFactory
Provides utility methods for instantiating objects with
dynamic, or 'soft' linkages. This is particularly useful
for instantiating abstract singletons, or replacing 'hard'
dependencies (often circular) with soft linkages that are resolved
at run-time.
User: josh
Date: Oct 21, 2003
Time: 8:23:12 AM
Constructor Summary | |
---|---|
ObjectFactory()
|
Method Summary | |
---|---|
static java.lang.Object |
createInstanceFromProperties(java.util.Properties properties,
java.lang.String propertyName,
java.lang.String defaultClassName,
boolean propertyRequired)
Creates an instance from the specified set of properties If the class implements Initializeable, it will be initialized. |
static java.lang.Object |
createInstanceFromPropertiesResource(java.lang.String resourceName,
java.lang.String propertyName,
java.lang.String defaultClassName,
boolean resourceAndPropertyRequired)
Creates an instance from the specified property in the specified properties-file resource, which will be loaded from the current thread's class loader. |
static java.lang.String |
getClasspathRoot(java.lang.Class c)
Returns the base part of the classpath where the specified class can be found. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectFactory()
Method Detail |
---|
public static java.lang.Object createInstanceFromPropertiesResource(java.lang.String resourceName, java.lang.String propertyName, java.lang.String defaultClassName, boolean resourceAndPropertyRequired) throws InitializationException, java.io.IOException
resourceName
- The name of the resource to load.propertyName
- The name of the property to look for in the resource.defaultClassName
- The default class name to use, if the resource was not found.resourceAndPropertyRequired
- Set to true if the resource and property name are required.
InitializationException
- if the resource could not be loaded.
java.io.IOException
- if the properties resource could not be readpublic static java.lang.Object createInstanceFromProperties(java.util.Properties properties, java.lang.String propertyName, java.lang.String defaultClassName, boolean propertyRequired) throws InitializationException
properties
- The properties to use.propertyName
- The name of the property to look for.defaultClassName
- The default class name to use, if the property was not found.propertyRequired
- Set to true if the property name is required.
InitializationException
- if the resource could not be loaded.public static java.lang.String getClasspathRoot(java.lang.Class c)
c
- The class to look up.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |