Class ObjectFactory<O,P>
java.lang.Object
org.frankframework.jdbc.datasource.ObjectFactory<O,P>
- Type Parameters:
O- Object class used by clients
- All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
AmqpConnectionFactoryFactory, JmsConnectionFactoryFactory, MongoClientFactoryFactory, MqttClientFactoryFactory, NonTransactionalDataSourceFactory
public abstract class ObjectFactory<O,P>
extends Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Baseclass for Object lookups.
Already created Objects are stored in a ConcurrentHashMap.
Objects will be searched in all available
IObjectLocators. If it cannot find the object in the first locator, it will attempt to do so in the next available one.
Every Objects can be augmented before it is added.- Author:
- Gerrit van Brakel, Niels Meijer
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedObjectFactory(Class<P> lookupClass, String resourcePrefix, String displayName) -
Method Summary
Modifier and TypeMethodDescription@NonNull OAdd and augment an Object to this factory so it can be used without the need of a lookup.voidprotected @NonNull OAllow implementing classes to augment the looked up object class 'O'.final voiddestroy()protected voiddestroyObject(O object) This method is called when the objects stored in this Factory are removed.protected final @NonNull Oget(@NonNull String name, @Nullable Properties environment) Returns the object matching the name and return type.@NonNull List<ObjectFactory.ObjectInfo> protected voidSubclasses which need to do their own work on destruction of this bean should override this method, which will be called after all factory objects have been closed.protected @NonNull ObjectFactory.ObjectInfotoObjectInfo(String name) Mapping fromto a information object, used for logging and console actions.
-
Field Details
-
log
protected final org.apache.logging.log4j.Logger log
-
-
Constructor Details
-
ObjectFactory
-
-
Method Details
-
augment
-
get
protected final @NonNull O get(@NonNull String name, @Nullable Properties environment) throws NoSuchElementException, IllegalStateException Returns the object matching the name and return type. If not cached yet, attempts to traverse allIObjectLocatorsto do so. If a new instance is created,augment(Object, String)is called to allow subclasses to wrap or modify the object.When using a JNDI environment it allows initial properties to use for JNDI lookups.
- Throws:
NoSuchElementException- when the object cannot be foundIllegalStateException- when an object definition can be found, but the object instance cannot be created
-
add
-
afterPropertiesSet
-
getObjectNames
-
getObjectInfo
-
toObjectInfo
Mapping fromto a information object, used for logging and console actions. -
destroy
-
postDestroy
-
destroyObject
-