public abstract class AbstractBrokerFactory extends Object implements BrokerFactory
BrokerFactory
that must be subclassed for a specific runtime.Modifier | Constructor and Description |
---|---|
protected |
AbstractBrokerFactory(OpenJPAConfiguration config)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addLifecycleListener(Object listener,
Class<?>[] classes)
Register a listener for lifecycle-related events on the specified
classes.
|
protected void |
addListeners(Broker broker)
Add factory-registered lifecycle listeners to the broker.
|
void |
addTransactionListener(Object listener)
Register a listener for transaction-related events on the specified
classes.
|
void |
assertOpen()
Throw an exception if the factory is closed.
|
void |
close()
Close the factory.
|
protected void |
configureBroker(BrokerImpl broker)
Configures the given broker with the current factory option settings.
|
protected DelegatingStoreManager |
createDelegatingStoreManager()
Create a DelegatingStoreManager for use with a Broker created by this factory.
|
protected Broker |
findBroker(String user,
String pass,
boolean managed)
Find a pooled broker, or return null if none.
|
protected Broker |
findTransactionalBroker(String user,
String pass)
Find a managed runtime broker associated with the
current transaction, or returns null if none.
|
OpenJPAConfiguration |
getConfiguration()
Return the configuration for this factory.
|
protected Object |
getFactoryInitializationBanner()
Return an object to be written to the log when this broker factory
initializes.
|
Collection<Broker> |
getOpenBrokers()
Returns a set of all the open brokers associated with this factory.
|
static AbstractBrokerFactory |
getPooledFactoryForKey(Object key)
Return the pooled factory matching the given key, or null
if none.
|
Object |
getPoolKey() |
Map<String,Object> |
getProperties()
Subclasses should override this method to add a
Platform
property listing the runtime platform, such as:
OpenJPA JDBC Edition: Oracle Database |
Set<String> |
getSupportedProperties()
Return all of the supported properties as a set of keys.
|
Object |
getUserObject(Object key)
Get the value for the specified key from the map of user objects.
|
boolean |
isClosed()
Returns true if this broker factory is closed.
|
void |
loadPersistentTypes(ClassLoader envLoader)
Load the configured persistent classes list.
|
void |
lock()
Synchronizes on an internal lock.
|
void |
makeReadOnly()
Freezes the configuration of this factory.
|
Broker |
newBroker()
Return a broker with default settings.
|
Broker |
newBroker(boolean managed,
int connRetainMode) |
Broker |
newBroker(String user,
String pass) |
Broker |
newBroker(String user,
String pass,
boolean managed,
int connRetainMode) |
Broker |
newBroker(String user,
String pass,
boolean managed,
int connRetainMode,
boolean findExisting)
Return a broker using the given credentials and in the given
transaction and connection retain mode, optionally finding
existing broker in the global transaction.
|
Broker |
newBroker(String user,
String pass,
boolean managed,
int connRetainMode,
boolean findExisting,
String cf1Name,
String cf2Name)
Return a new broker using the supplied
credentials
transaction management mode
connectionRetainMode
connectionFactories
|
protected BrokerImpl |
newBrokerImpl(String user,
String pass)
Return a broker configured with the proper settings.
|
protected abstract StoreManager |
newStoreManager()
Return a new StoreManager for this runtime.
|
protected static void |
pool(Object key,
AbstractBrokerFactory factory)
Register
factory in the pool under key . |
void |
postCreationCallback()
This method is invoked AFTER a BrokerFactory has been instantiated.
|
Object |
putUserObject(Object key,
Object val)
Put the specified key-value pair into the map of user objects.
|
protected Object |
readResolve()
Replaces the factory with this JVMs pooled version if it exists.
|
protected void |
releaseBroker(BrokerImpl broker)
Release
broker from any internal data structures. |
void |
removeLifecycleListener(Object listener)
Remove a listener for lifecycle-related events.
|
void |
removeTransactionListener(Object listener)
Remove a listener for transaction-related events.
|
protected void |
setup()
Setup transient state used by this factory based on the
current configuration, which will subsequently be locked down.
|
protected static Object |
toPoolKey(Map<String,Object> map)
Return an internal factory pool key for the given configuration.
|
void |
unlock()
Release the internal lock.
|
protected AbstractBrokerFactory(OpenJPAConfiguration config)
protected static Object toPoolKey(Map<String,Object> map)
protected static void pool(Object key, AbstractBrokerFactory factory)
factory
in the pool under key
.public static AbstractBrokerFactory getPooledFactoryForKey(Object key)
getPoolKey()
.public OpenJPAConfiguration getConfiguration()
getConfiguration
in interface BrokerFactory
public Broker newBroker()
BrokerFactory
newBroker
in interface BrokerFactory
public Broker newBroker(boolean managed, int connRetainMode)
public Broker newBroker(String user, String pass, boolean managed, int connRetainMode, boolean findExisting)
BrokerFactory
newBroker
in interface BrokerFactory
public Broker newBroker(String user, String pass, boolean managed, int connRetainMode, boolean findExisting, String cf1Name, String cf2Name)
BrokerFactory
newBroker
in interface BrokerFactory
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
- ConnectionRetainMode
findExisting
- Whether the internal pool of brokers should be used.cf1Name
- JTA ConnectionFactory to usecf2Name
- Non-JTA ConnectionFactory to use.protected void addListeners(Broker broker)
public void loadPersistentTypes(ClassLoader envLoader)
public void addLifecycleListener(Object listener, Class<?>[] classes)
BrokerFactory
addLifecycleListener
in interface BrokerFactory
public void removeLifecycleListener(Object listener)
BrokerFactory
removeLifecycleListener
in interface BrokerFactory
public void addTransactionListener(Object listener)
BrokerFactory
Broker
s created
from this instance moving forward.addTransactionListener
in interface BrokerFactory
public void removeTransactionListener(Object listener)
BrokerFactory
Broker
s created from this instance.removeTransactionListener
in interface BrokerFactory
public boolean isClosed()
isClosed
in interface BrokerFactory
public void close()
BrokerFactory
close
in interface BrokerFactory
close
in interface Closeable
public Map<String,Object> getProperties()
Platform
property listing the runtime platform, such as:
OpenJPA JDBC Edition: Oracle Database
getProperties
in interface BrokerFactory
public Set<String> getSupportedProperties()
BrokerFactory
getSupportedProperties
in interface BrokerFactory
public Object getUserObject(Object key)
BrokerFactory
getUserObject
in interface BrokerFactory
public Object putUserObject(Object key, Object val)
BrokerFactory
putUserObject
in interface BrokerFactory
public void lock()
BrokerFactory
lock
in interface BrokerFactory
public void unlock()
BrokerFactory
unlock
in interface BrokerFactory
protected Object readResolve() throws ObjectStreamException
ObjectStreamException
protected abstract StoreManager newStoreManager()
newBroker()
method.protected Broker findBroker(String user, String pass, boolean managed)
newStoreManager()
so that factory subclasses implementing
pooling can return a matching manager before a new StoreManager
is created.protected BrokerImpl newBrokerImpl(String user, String pass)
protected void setup()
protected Broker findTransactionalBroker(String user, String pass)
protected void configureBroker(BrokerImpl broker)
public void makeReadOnly()
protected Object getFactoryInitializationBanner()
public void assertOpen()
assertOpen
in interface BrokerFactory
public Collection<Broker> getOpenBrokers()
protected void releaseBroker(BrokerImpl broker)
broker
from any internal data structures. This
is invoked by broker
after the broker is fully closed.public Object getPoolKey()
protected DelegatingStoreManager createDelegatingStoreManager()
Create a DelegatingStoreManager for use with a Broker created by this factory. If a DataCache has been enabled a DataCacheStoreManager will be returned.
If no DataCache is in use an ROPStoreManager will be returned.
public void postCreationCallback()
postCreationCallback
in interface BrokerFactory
Copyright © 2006–2020 Apache Software Foundation. All rights reserved.