Package org.drools.persistence.jpa
Class AbstractPersistenceContextManager
- java.lang.Object
-
- org.drools.persistence.jpa.AbstractPersistenceContextManager
-
- Direct Known Subclasses:
JpaPersistenceContextManager
public abstract class AbstractPersistenceContextManager extends Object
This class managesJpaPersistenceContextobjects, and the underlying persistence context (EntityManager) instances for a persistentKieSessionand other infrastructure classes that use persistence in KIE projects. (For reference in the following documentation: theEntityManageris the class used to represent a persistence context) There are 2 issues to take into account when looking at or modifying the code here:- One of the features made available here is the ability for the user to supply their own (Command Scoped) persistence
context for use by the
KieSession - However, significant race-conditions arise when a Command Scoped persistence context is used in one persistent
KieSessionby multiple threads. In other words, when multiple threads call operations on a Singleton persistentKieSession.
ThreadLocalinstances for two things:- The internal Command Scoped
EntityManagerinstance.
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.persistence.EntityManagerappScopedEntityManagerprotected javax.persistence.EntityManagercmdScopedEntityManagerprotected javax.persistence.EntityManagerFactoryemfprotected org.kie.api.runtime.Environmentenvprotected booleaninternalAppScopedEntityManagerFlagprotected booleaninternalCmdScopedEntityManagerFlagprotected org.drools.persistence.api.TransactionManagertxm
-
Constructor Summary
Constructors Constructor Description AbstractPersistenceContextManager(org.kie.api.runtime.Environment env)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()voidendCommandScopedEntityManager()javax.persistence.EntityManagergetApplicationScopedEntityManager()javax.persistence.EntityManagergetCommandScopedEntityManager()protected javax.persistence.EntityManagergetInternalCommandScopedEntityManager()voidresetApplicationScopedPersistenceContext()
-
-
-
Field Detail
-
env
protected final org.kie.api.runtime.Environment env
-
emf
protected final javax.persistence.EntityManagerFactory emf
-
txm
protected final org.drools.persistence.api.TransactionManager txm
-
appScopedEntityManager
protected volatile javax.persistence.EntityManager appScopedEntityManager
-
cmdScopedEntityManager
protected volatile javax.persistence.EntityManager cmdScopedEntityManager
-
internalAppScopedEntityManagerFlag
protected volatile boolean internalAppScopedEntityManagerFlag
-
internalCmdScopedEntityManagerFlag
protected volatile boolean internalCmdScopedEntityManagerFlag
-
-
Method Detail
-
getApplicationScopedEntityManager
public javax.persistence.EntityManager getApplicationScopedEntityManager()
-
getCommandScopedEntityManager
public javax.persistence.EntityManager getCommandScopedEntityManager()
-
endCommandScopedEntityManager
public void endCommandScopedEntityManager()
-
dispose
public void dispose()
-
resetApplicationScopedPersistenceContext
public void resetApplicationScopedPersistenceContext()
-
getInternalCommandScopedEntityManager
protected javax.persistence.EntityManager getInternalCommandScopedEntityManager()
-
-