Package org.drools.persistence.jpa
Class JpaPersistenceContextManager
- java.lang.Object
-
- org.drools.persistence.jpa.AbstractPersistenceContextManager
-
- org.drools.persistence.jpa.JpaPersistenceContextManager
-
- All Implemented Interfaces:
org.drools.persistence.api.PersistenceContextManager
public class JpaPersistenceContextManager extends AbstractPersistenceContextManager implements org.drools.persistence.api.PersistenceContextManager
This class managesJpaPersistenceContext
objects, and the underlying persistence context (EntityManager
) instances for a persistentKieSession
and other infrastructure classes that use persistence in KIE projects. (For reference in the following documentation: theEntityManager
is 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
KieSession
by multiple threads. In other words, when multiple threads call operations on a Singleton persistentKieSession
.
ThreadLocal
instances for two things:- The internal Command Scoped
EntityManager
instance.
-
-
Field Summary
-
Fields inherited from class org.drools.persistence.jpa.AbstractPersistenceContextManager
appScopedEntityManager, cmdScopedEntityManager, emf, env, internalAppScopedEntityManagerFlag, internalCmdScopedEntityManagerFlag, txm
-
-
Constructor Summary
Constructors Constructor Description JpaPersistenceContextManager(org.kie.api.runtime.Environment env)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginCommandScopedEntityManager()
org.drools.persistence.api.PersistenceContext
getApplicationScopedPersistenceContext()
org.drools.persistence.api.PersistenceContext
getCommandScopedPersistenceContext()
-
Methods inherited from class org.drools.persistence.jpa.AbstractPersistenceContextManager
dispose, endCommandScopedEntityManager, getApplicationScopedEntityManager, getCommandScopedEntityManager, getInternalCommandScopedEntityManager, resetApplicationScopedPersistenceContext
-
-
-
-
Method Detail
-
getApplicationScopedPersistenceContext
public org.drools.persistence.api.PersistenceContext getApplicationScopedPersistenceContext()
- Specified by:
getApplicationScopedPersistenceContext
in interfaceorg.drools.persistence.api.PersistenceContextManager
-
getCommandScopedPersistenceContext
public org.drools.persistence.api.PersistenceContext getCommandScopedPersistenceContext()
- Specified by:
getCommandScopedPersistenceContext
in interfaceorg.drools.persistence.api.PersistenceContextManager
-
beginCommandScopedEntityManager
public void beginCommandScopedEntityManager()
- Specified by:
beginCommandScopedEntityManager
in interfaceorg.drools.persistence.api.PersistenceContextManager
-
-