Class PrototypeFactory<K,T>
java.lang.Object
org.apache.openjpa.persistence.jest.PrototypeFactory<K,T>
A factory for a specific type of objects registered by a key.
The client registers a type indexed by name.
The client can get a new instance of the registered type.
The requested registered type not necessarily have to have a no-arg
constructor. The constructor arguments can be passed during
type of key for this registry
base type of the objects to construct
new instance
request. Based on the
arguments, a matching constructor, if any, is located and invoked.
- Author:
- Pinaki Poddar
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the keys registered in this factory.newInstance
(K key, Object... args) Create a new instance of the type registered before with the given key, if any.void
Register the given class with the given key.
-
Constructor Details
-
PrototypeFactory
public PrototypeFactory()
-
-
Method Details
-
register
Register the given class with the given key.- Parameters:
key
- a non-null key.prototype
- a type.
-
newInstance
Create a new instance of the type registered before with the given key, if any. The given arguments are used to identify a constructor of the registered type and passed to the constructor of the registered type.- Parameters:
key
- a key to identify a registered type.args
- arguments to pass to the constructor of the type.- Returns:
- null if no type has been registered against the given key.
-
getRegisteredKeys
Gets the keys registered in this factory.- Returns:
- immutable set of registered keys.
-