| java.lang.Object org.apache.openejb.persistence.JtaEntityManagerRegistry
JtaEntityManagerRegistry | public class JtaEntityManagerRegistry (Code) | | The JtaEntityManagerRegistry tracks JTA entity managers for transation and extended scoped
entity managers. A signle instance of this object should be created and shared by all
JtaEntityManagers in the server instance. Failure to do this will result in multiple entity
managers being created for a single persistence until, and that will result in cache
incoherence.
|
Constructor Summary | |
public | JtaEntityManagerRegistry(TransactionSynchronizationRegistry transactionSynchronizationRegistry) Creates a JtaEntityManagerRegistry using the specified transactionSynchronizationRegistry for the registry
if transaction associated entity managers. |
Method Summary | |
public void | addEntityManagers(String deploymentId, Object primaryKey, Map<EntityManagerFactory, EntityManager> entityManagers) Adds the entity managers for the specified component to the registry. | public EntityManager | getEntityManager(EntityManagerFactory entityManagerFactory, Map properties, boolean extended) Gets an entity manager instance from the transaction registry, extended regitry or for a transaction scoped
entity manager, creates a new one when an exisitng instance is not found.
It is important that a component adds extended scoped entity managers to this registry when the component is
entered and removes them when exited. | public EntityManager | getInheritedEntityManager(EntityManagerFactory entityManagerFactory) Gets an exiting extended entity manager created by a component down the call stack. | public boolean | isTransactionActive() | public void | removeEntityManagers(String deploymentId, Object primaryKey) Removed the registered entity managers for the specified component. | public void | transactionStarted(String deploymentId, Object primaryKey) Notifies the registry that a user transaction has been started or the specified component. |
JtaEntityManagerRegistry | public JtaEntityManagerRegistry(TransactionSynchronizationRegistry transactionSynchronizationRegistry)(Code) | | Creates a JtaEntityManagerRegistry using the specified transactionSynchronizationRegistry for the registry
if transaction associated entity managers.
|
addEntityManagers | public void addEntityManagers(String deploymentId, Object primaryKey, Map<EntityManagerFactory, EntityManager> entityManagers) throws EntityManagerAlreadyRegisteredException(Code) | | Adds the entity managers for the specified component to the registry. This should be called when the component
is entered.
Parameters: deploymentId - the id of the component Parameters: entityManagers - the entity managers to register throws: EntityManagerAlreadyRegisteredException - if an entity manager is already registered with the transactionfor one of the supplied entity manager factories; for EJBs this should be caught and rethown as an EJBException |
getEntityManager | public EntityManager getEntityManager(EntityManagerFactory entityManagerFactory, Map properties, boolean extended) throws IllegalStateException(Code) | | Gets an entity manager instance from the transaction registry, extended regitry or for a transaction scoped
entity manager, creates a new one when an exisitng instance is not found.
It is important that a component adds extended scoped entity managers to this registry when the component is
entered and removes them when exited. If this registration is not preformed, an IllegalStateException will
be thrown when entity manger is fetched.
Parameters: entityManagerFactory - the entity manager factory from which an entity manager is required Parameters: properties - the properties passed to the entity manager factory when an entity manager is created Parameters: extended - is the entity manager an extended context the new entity manager throws: IllegalStateException - if the entity manger is extended and there is not an existing entity managerinstance already registered |
getInheritedEntityManager | public EntityManager getInheritedEntityManager(EntityManagerFactory entityManagerFactory)(Code) | | Gets an exiting extended entity manager created by a component down the call stack.
Parameters: entityManagerFactory - the entity manager factory from which an entity manager is needed the existing entity manager or null if one is not found |
isTransactionActive | public boolean isTransactionActive()(Code) | | Is a transaction active?
true if a transaction is active; false otherwise |
removeEntityManagers | public void removeEntityManagers(String deploymentId, Object primaryKey)(Code) | | Removed the registered entity managers for the specified component.
Parameters: deploymentId - the id of the component |
transactionStarted | public void transactionStarted(String deploymentId, Object primaryKey)(Code) | | Notifies the registry that a user transaction has been started or the specified component. When a transaction
is started for a component with registered extended entity managers, the entity managers are enrolled in the
transaction.
Parameters: deploymentId - the id of the component |
|
|