public class JpaPersistenceContextManager extends AbstractPersistenceContextManager implements PersistenceContextManager
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: KieSessionKieSession by multiple threads. In other words, when multiple threads call operations on a Singleton persistent
KieSession.ThreadLocal instances for two things:EntityManager instance.appScopedEntityManager, cmdScopedEntityManager, emf, env, internalAppScopedEntityManagerFlag, internalCmdScopedEntityManagerFlag, txm| Constructor and Description |
|---|
JpaPersistenceContextManager(org.kie.api.runtime.Environment env) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginCommandScopedEntityManager()
This method should be called at the beginning of a
CommandExecutor.execute(org.kie.api.command.Command) method,
when the given CommandService instance is responsible for handling persistence. |
PersistenceContext |
getApplicationScopedPersistenceContext() |
PersistenceContext |
getCommandScopedPersistenceContext() |
dispose, endCommandScopedEntityManager, getApplicationScopedEntityManager, getCommandScopedEntityManager, getInternalCommandScopedEntityManagerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdispose, endCommandScopedEntityManagerpublic JpaPersistenceContextManager(org.kie.api.runtime.Environment env)
public PersistenceContext getApplicationScopedPersistenceContext()
getApplicationScopedPersistenceContext in interface PersistenceContextManagerPersistenceContext instance containing the Application Scoped EntityManager.public PersistenceContext getCommandScopedPersistenceContext()
getCommandScopedPersistenceContext in interface PersistenceContextManagerPersistenceContext instance containing the Command Scoped EntityManager.public void beginCommandScopedEntityManager()
PersistenceContextManagerCommandExecutor.execute(org.kie.api.command.Command) method,
when the given CommandService instance is responsible for handling persistence.
See the SingleSessionCommandService class.
The first responsibility of this method is to make sure that the Command Scoped EntityManager (CSEM) joins
the ongoing transaction.
When the CSEM is internally managed, this method is also responsible for creating a new CSEM for use during execution
of the Command or operation being executed by the KieSession.beginCommandScopedEntityManager in interface PersistenceContextManagerCopyright © 2001–2015 JBoss by Red Hat. All rights reserved.