|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.openejb.persistence.JtaEntityManagerRegistry
public class JtaEntityManagerRegistry
The JtaEntityManagerRegistry tracks JTA entity managers for transaction and extended scoped entity managers. A single 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.
| Nested Class Summary | |
|---|---|
static class |
JtaEntityManagerRegistry.EntityManagerTracker
This object is used track all EntityManagers inherited in order to effectively close it when the latest Extended persistence context is no more accessed. |
| Constructor Summary | |
|---|---|
JtaEntityManagerRegistry(TransactionSynchronizationRegistry transactionSynchronizationRegistry)
Creates a JtaEntityManagerRegistry using the specified transactionSynchronizationRegistry for the registry if transaction associated entity managers. |
|
| Method Summary | |
|---|---|
void |
addEntityManagers(String deploymentId,
Object primaryKey,
Map<javax.persistence.EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> entityManagers)
Adds the entity managers for the specified component to the registry. |
javax.persistence.EntityManager |
getEntityManager(javax.persistence.EntityManagerFactory entityManagerFactory,
Map properties,
boolean extended,
String unitName)
Gets an entity manager instance from the transaction registry, extended registry or for a transaction scoped entity manager, creates a new one when an existing instance is not found. |
JtaEntityManagerRegistry.EntityManagerTracker |
getInheritedEntityManager(javax.persistence.EntityManagerFactory entityManagerFactory)
Gets an exiting extended entity manager created by a component down the call stack. |
boolean |
isTransactionActive()
Is a transaction active? |
Map<javax.persistence.EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> |
removeEntityManagers(String deploymentId,
Object primaryKey)
Removed the registered entity managers for the specified component. |
void |
transactionStarted(String deploymentId,
Object primaryKey)
Notifies the registry that a user transaction has been started or the specified component. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JtaEntityManagerRegistry(TransactionSynchronizationRegistry transactionSynchronizationRegistry)
| Method Detail |
|---|
public javax.persistence.EntityManager getEntityManager(javax.persistence.EntityManagerFactory entityManagerFactory,
Map properties,
boolean extended,
String unitName)
throws IllegalStateException
entityManagerFactory - the entity manager factory from which an entity manager is requiredproperties - the properties passed to the entity manager factory when an entity manager is createdextended - is the entity manager an extended contextunitName -
IllegalStateException - if the entity manger is extended and there is not an existing entity manager
instance already registered
public void addEntityManagers(String deploymentId,
Object primaryKey,
Map<javax.persistence.EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> entityManagers)
throws EntityManagerAlreadyRegisteredException
deploymentId - the id of the componententityManagers - the entity managers to register
EntityManagerAlreadyRegisteredException - if an entity manager is already registered with the transaction
for one of the supplied entity manager factories; for EJBs this should be caught and rethown as an EJBException
public Map<javax.persistence.EntityManagerFactory,JtaEntityManagerRegistry.EntityManagerTracker> removeEntityManagers(String deploymentId,
Object primaryKey)
deploymentId - the id of the component
public JtaEntityManagerRegistry.EntityManagerTracker getInheritedEntityManager(javax.persistence.EntityManagerFactory entityManagerFactory)
entityManagerFactory - the entity manager factory from which an entity manager is needed
public void transactionStarted(String deploymentId,
Object primaryKey)
deploymentId - the id of the componentpublic boolean isTransactionActive()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||