oracle.cle.util
Class ObjectFactory
java.lang.Object
|
+--oracle.cle.util.ObjectFactory
- Direct Known Subclasses:
- HandlerFactory
- public abstract class ObjectFactory
- extends java.lang.Object
A Class used for instantiating objects based on entries specified
in the deployment.properties
file. This is useful when
working with interfaces and you would like to have runtime options for
defining the implementations of those interfaces.
Typical usage(s):
// You can use a string argument...
Foo foo = (Foo)ObjectFactory.getObject("foo");
// .. or a class argument...
Foo foo2 = (Foo)ObjectFactory.getObject(mypackage.Foo.class);
Here are what the deployment.properties
file
entries would look like for the example given above:
# use a key to indicate which class to instantiate
foo=oracle.demo.foo.FooImpl
# use a fully qualified classname to indicate which class to instantiate
mypackage.Foo=oracle.demo.foo.FooImpl
NOTE: The concrete class returned by the factory DOES NOT need to
end with the Impl
suffix.
- See Also:
DeploymentManager
Method Summary |
static java.lang.Object |
getObject(java.lang.Class aClass)
Returns the appropriate object implementation for the
specified Class' fully qualified name. |
static java.lang.Object |
getObject(java.lang.String key)
Returns the appropriate object implementation for the
specified String. |
static void |
main(java.lang.String[] args)
A test expecting the following to be present in
deployment.properties :
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ObjectFactory
public ObjectFactory()
getObject
public static java.lang.Object getObject(java.lang.String key)
throws java.lang.Exception
- Returns the appropriate object implementation for the
specified String. NOTE: The string must be the key of an
entry in the
deployment.properties
file. The value
of the property must be the class that will be instantiated.
getObject
public static java.lang.Object getObject(java.lang.Class aClass)
throws java.lang.Exception
- Returns the appropriate object implementation for the
specified Class' fully qualified name.
NOTE: The class' fully qualified name must be the key of an
entry in the
deployment.properties
file. The value
of the property must be the class that will be instantiated.
main
public static void main(java.lang.String[] args)
- A test expecting the following to be present in
deployment.properties
:
foo=java.util.Hashtable
java.lang.String=java.util.Vector
Copyright © 2003 ORACLE Corp. All Rights Reserved.