Drools :: Persistence :: JPA 6.2.0.CR3

org.drools.persistence.jpa
Class AbstractPersistenceContextManager

java.lang.Object
  extended by org.drools.persistence.jpa.AbstractPersistenceContextManager
Direct Known Subclasses:
JpaPersistenceContextManager

public abstract class AbstractPersistenceContextManager
extends Object

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:
  1. 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
  2. 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 persistent KieSession.
This class uses ThreadLocal instances for two things:
  1. The internal Command Scoped EntityManager instance.


Field Summary
protected  javax.persistence.EntityManager appScopedEntityManager
           
protected  javax.persistence.EntityManager cmdScopedEntityManager
           
protected  javax.persistence.EntityManagerFactory emf
           
protected  org.kie.api.runtime.Environment env
           
protected  boolean internalAppScopedEntityManagerFlag
           
protected  boolean internalCmdScopedEntityManagerFlag
           
protected  TransactionManager txm
           
 
Constructor Summary
AbstractPersistenceContextManager(org.kie.api.runtime.Environment env)
           
 
Method Summary
 void dispose()
           
 void endCommandScopedEntityManager()
           
 javax.persistence.EntityManager getApplicationScopedEntityManager()
           
 javax.persistence.EntityManager getCommandScopedEntityManager()
           
protected  javax.persistence.EntityManager getInternalCommandScopedEntityManager()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

env

protected final org.kie.api.runtime.Environment env

emf

protected final javax.persistence.EntityManagerFactory emf

txm

protected final 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
Constructor Detail

AbstractPersistenceContextManager

public AbstractPersistenceContextManager(org.kie.api.runtime.Environment env)
Method Detail

getApplicationScopedEntityManager

public javax.persistence.EntityManager getApplicationScopedEntityManager()

getCommandScopedEntityManager

public javax.persistence.EntityManager getCommandScopedEntityManager()

endCommandScopedEntityManager

public void endCommandScopedEntityManager()

dispose

public void dispose()

getInternalCommandScopedEntityManager

protected javax.persistence.EntityManager getInternalCommandScopedEntityManager()

Drools :: Persistence :: JPA 6.2.0.CR3

Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.