Package org.drools.persistence.jpa
Class AbstractPersistenceContextManager
java.lang.Object
org.drools.persistence.jpa.AbstractPersistenceContextManager
- Direct Known Subclasses:
JpaPersistenceContextManager
This class manages
JpaPersistenceContext objects, and the underlying persistence context (EntityManager)
instances for a persistent KieSession and other infrastructure classes that use persistence in KIE projects.
(For reference in the following documentation: the EntityManager 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
KieSessionby multiple threads. In other words, when multiple threads call operations on a Singleton persistentKieSession.
ThreadLocal instances for two things:- The internal Command Scoped
EntityManagerinstance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected jakarta.persistence.EntityManagerprotected jakarta.persistence.EntityManagerprotected final jakarta.persistence.EntityManagerFactoryprotected final Environmentprotected booleanprotected booleanprotected final TransactionManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()voidjakarta.persistence.EntityManagerjakarta.persistence.EntityManagerprotected jakarta.persistence.EntityManagervoid
-
Field Details
-
env
-
emf
protected final jakarta.persistence.EntityManagerFactory emf -
txm
-
appScopedEntityManager
protected volatile jakarta.persistence.EntityManager appScopedEntityManager -
cmdScopedEntityManager
protected volatile jakarta.persistence.EntityManager cmdScopedEntityManager -
internalAppScopedEntityManagerFlag
protected volatile boolean internalAppScopedEntityManagerFlag -
internalCmdScopedEntityManagerFlag
protected volatile boolean internalCmdScopedEntityManagerFlag
-
-
Constructor Details
-
AbstractPersistenceContextManager
-
-
Method Details
-
getApplicationScopedEntityManager
public jakarta.persistence.EntityManager getApplicationScopedEntityManager() -
getCommandScopedEntityManager
public jakarta.persistence.EntityManager getCommandScopedEntityManager() -
endCommandScopedEntityManager
public void endCommandScopedEntityManager() -
dispose
public void dispose() -
resetApplicationScopedPersistenceContext
public void resetApplicationScopedPersistenceContext() -
getInternalCommandScopedEntityManager
protected jakarta.persistence.EntityManager getInternalCommandScopedEntityManager()
-