Package org.apache.openjpa.kernel
Class DelegatingBrokerFactory
java.lang.Object
org.apache.openjpa.kernel.DelegatingBrokerFactory
- All Implemented Interfaces:
Serializable,BrokerFactory,Closeable
Delegating broker factory that can also perform exception translation
for use in facades.
- Since:
- 0.4.0
- Author:
- Abe White
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDelegatingBrokerFactory(BrokerFactory factory) Constructor; supply delegate.DelegatingBrokerFactory(BrokerFactory factory, RuntimeExceptionTranslator trans) Constructor; supply delegate and exception translator. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLifecycleListener(Object listener, Class[] classes) Register a listener for lifecycle-related events on the specified classes.voidaddTransactionListener(Object listener) Register a listener for transaction-related events on the specified classes.voidassert that this broker is open.voidclose()Close the factory.booleanReturn the configuration for this factory.Return the direct delegate.Return the native delegate.Return properties describing this runtime.Return all of the supported properties as a set of keys.getUserObject(Object key) Get the value for the specified key from the map of user objects.inthashCode()booleanisClosed()Returns true if this broker factory is closed.voidlock()Synchronizes on an internal lock.Return a broker with default settings.Return a broker using the given credentials and in the given transaction and connection retain mode, optionally finding existing broker in the global transaction.newBroker(String user, String pass, boolean managed, int connRetainMode, boolean findExisting, String cfName, String cf2Name) Return a new broker using the supplied credentials transaction management mode connectionRetainMode connectionFactoriesvoidThis method is invoked AFTER a BrokerFactory has been instantiated.putUserObject(Object key, Object val) Put the specified key-value pair into the map of user objects.voidremoveLifecycleListener(Object listener) Remove a listener for lifecycle-related events.voidremoveTransactionListener(Object listener) Remove a listener for transaction-related events.protected RuntimeExceptionTranslate the OpenJPA exception.voidunlock()Release the internal lock.
-
Constructor Details
-
DelegatingBrokerFactory
Constructor; supply delegate. -
DelegatingBrokerFactory
Constructor; supply delegate and exception translator.
-
-
Method Details
-
getDelegate
Return the direct delegate. -
getInnermostDelegate
Return the native delegate. -
hashCode
public int hashCode() -
equals
-
translate
Translate the OpenJPA exception. -
getConfiguration
Description copied from interface:BrokerFactoryReturn the configuration for this factory.- Specified by:
getConfigurationin interfaceBrokerFactory
-
getProperties
Description copied from interface:BrokerFactoryReturn properties describing this runtime.- Specified by:
getPropertiesin interfaceBrokerFactory
-
getSupportedProperties
Description copied from interface:BrokerFactoryReturn all of the supported properties as a set of keys. If a property has multiple keys, all keys will be returned.- Specified by:
getSupportedPropertiesin interfaceBrokerFactory
-
putUserObject
Description copied from interface:BrokerFactoryPut the specified key-value pair into the map of user objects.- Specified by:
putUserObjectin interfaceBrokerFactory
-
getUserObject
Description copied from interface:BrokerFactoryGet the value for the specified key from the map of user objects.- Specified by:
getUserObjectin interfaceBrokerFactory
-
newBroker
Description copied from interface:BrokerFactoryReturn a broker with default settings.- Specified by:
newBrokerin interfaceBrokerFactory
-
newBroker
public Broker newBroker(String user, String pass, boolean managed, int connRetainMode, boolean findExisting) Description copied from interface:BrokerFactoryReturn a broker using the given credentials and in the given transaction and connection retain mode, optionally finding existing broker in the global transaction.- Specified by:
newBrokerin interfaceBrokerFactory
-
newBroker
public Broker newBroker(String user, String pass, boolean managed, int connRetainMode, boolean findExisting, String cfName, String cf2Name) Description copied from interface:BrokerFactoryReturn a new broker using the supplied- credentials
- transaction management mode
- connectionRetainMode
- connectionFactories
- Specified by:
newBrokerin interfaceBrokerFactory- Parameters:
user- Username to use when obtaining a connection. Will be ignored if a connection factory is obtained from JNDI.pass- Password to use when obtaining a connection. Will be ignored if a connection factory is obtained from JNDI.managed- Whether managed transactions will be used by this BrokerconnRetainMode-ConnectionRetainModefindExisting- Whether the internal pool of brokers should be used.cfName- JTA ConnectionFactory to usecf2Name- Non-JTA ConnectionFactory to use.- Returns:
- A Broker which matches the provided criteria.
-
addLifecycleListener
Description copied from interface:BrokerFactoryRegister a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener. The listener will be passed on to all new brokers.- Specified by:
addLifecycleListenerin interfaceBrokerFactory
-
removeLifecycleListener
Description copied from interface:BrokerFactoryRemove a listener for lifecycle-related events.- Specified by:
removeLifecycleListenerin interfaceBrokerFactory
-
addTransactionListener
Description copied from interface:BrokerFactoryRegister a listener for transaction-related events on the specified classes. It will be registered with allBrokers created from this instance moving forward.- Specified by:
addTransactionListenerin interfaceBrokerFactory
-
removeTransactionListener
Description copied from interface:BrokerFactoryRemove a listener for transaction-related events. It will no longer be registered with newBrokers created from this instance.- Specified by:
removeTransactionListenerin interfaceBrokerFactory
-
close
public void close()Description copied from interface:BrokerFactoryClose the factory.- Specified by:
closein interfaceBrokerFactory- Specified by:
closein interfaceCloseable
-
isClosed
public boolean isClosed()Description copied from interface:BrokerFactoryReturns true if this broker factory is closed.- Specified by:
isClosedin interfaceBrokerFactory
-
lock
public void lock()Description copied from interface:BrokerFactorySynchronizes on an internal lock.- Specified by:
lockin interfaceBrokerFactory
-
unlock
public void unlock()Description copied from interface:BrokerFactoryRelease the internal lock.- Specified by:
unlockin interfaceBrokerFactory
-
assertOpen
public void assertOpen()Description copied from interface:BrokerFactoryassert that this broker is open. If the broker has been closed an IllegalStateException will be thrown with information on when the broker was closed.- Specified by:
assertOpenin interfaceBrokerFactory
-
postCreationCallback
public void postCreationCallback()Description copied from interface:BrokerFactoryThis method is invoked AFTER a BrokerFactory has been instantiated.- Specified by:
postCreationCallbackin interfaceBrokerFactory
-