public class ObjectFactory<T>
extends java.lang.Object
Constructor and Description |
---|
ObjectFactory(java.lang.Class<T> clazz)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
T |
createObject(java.lang.String spec)
Constructs and returns an object from one of the classes registered
with this factory.
|
java.lang.Class<T> |
getFactoryClass()
Returns the class of which any object created by this factory
is guaranteed to be an instance.
|
java.lang.String[] |
getNickNames()
Returns a list of the nicknames which have been registered.
|
boolean |
isRegistered(java.lang.String name)
Indicates whether this factory knows about a given name.
|
void |
register(java.lang.String nickName,
java.lang.String className)
Registers a class with its nickname.
|
public ObjectFactory(java.lang.Class<T> clazz)
clazz
- type which must be a supertype of any class registered
with this factorypublic java.lang.Class<T> getFactoryClass()
public void register(java.lang.String nickName, java.lang.String className)
nickName
- nicknameclassName
- fully-qualified class namepublic java.lang.String[] getNickNames()
public boolean isRegistered(java.lang.String name)
name
- namename
can sensibly be passed to
createObject(java.lang.String)
public T createObject(java.lang.String spec) throws LoadException
spec
- classname/nickname of class to instantiate,
followed by optional config textLoadException
- if the load fails for unsurprising reasonsBeanConfig