@Service(value="blPersistenceService") public class PersistenceServiceImpl extends Object implements PersistenceService, org.springframework.context.SmartLifecycle
EntityManager
or PlatformTransactionManager
,
based on a class and TargetModeType
. This functionality is
especially useful when multiple PersistenceUnit
s are in use.
Note: All "default" items reference blPU, which is used to manage most Broadleaf entities in the Admin.Modifier and Type | Field and Description |
---|---|
protected Map<String,Map<String,Object>> |
defaultTargetModeMap |
protected static String |
ENTITY_MANAGER_KEY |
protected EntityConfiguration |
entityConfiguration |
protected List<javax.persistence.EntityManager> |
entityManagers |
protected static org.apache.commons.logging.Log |
LOG |
protected List<Map<String,Map<String,Object>>> |
targetModeMaps |
protected static String |
TRANSACTION_MANAGER_KEY |
protected StreamingTransactionCapableUtil |
transUtil |
Constructor and Description |
---|
PersistenceServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected String |
buildEJB3ConfigDaoCacheKey(Class<?> clazz) |
protected String |
buildManagerCacheKey(String targetMode,
Class<?> clazz) |
protected String |
buildManagerCacheKey(String targetMode,
String className) |
Class<?> |
getCeilingImplClassFromEntityManagers(String className)
Retrieves the topmost implementation for the given className by checking each registered
EntityManager . |
protected Class<?> |
getClassForName(String className) |
javax.persistence.EntityManager |
getEntityManager(Map<String,Object> managerMap)
Gathers the
EntityManager from the provided managerMap |
protected String |
getManagedClassName(String className) |
int |
getPhase() |
org.springframework.transaction.PlatformTransactionManager |
getTransactionManager(Map<String,Object> managerMap)
Gathers the
PlatformTransactionManager from the provided managerMap |
javax.persistence.EntityManager |
identifyDefaultEntityManager(TargetModeType targetModeType)
Identifies the default
EntityManager for the given targetModeType
NOTE: This assumes that the EntityManager is based on blPU |
org.springframework.transaction.PlatformTransactionManager |
identifyDefaultTransactionManager(TargetModeType targetModeType)
Identifies the default
PlatformTransactionManager for the given targetModeType
NOTE: This assumes that the PlatformTransactionManager is based on blPU |
javax.persistence.EntityManager |
identifyEntityManager(Class entityClass)
Identifies the
EntityManager for the given entityClass, using the default targetModeType of TargetModeType.SANDBOX |
javax.persistence.EntityManager |
identifyEntityManager(Class entityClass,
TargetModeType targetModeType)
Identifies the
EntityManager for the given entityClass and targetModeType |
org.springframework.transaction.PlatformTransactionManager |
identifyTransactionManager(String className,
TargetModeType targetModeType)
Identifies the
PlatformTransactionManager for the given className and targetModeType |
protected void |
initializeEntityManagerCache() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
protected void |
populateCaches(String targetMode,
Map<String,Object> managerMap) |
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
boolean |
validateEntityClassName(String entityClassName)
Determine if a test class name represents a known entity class registered with Hibernate
|
protected static final org.apache.commons.logging.Log LOG
protected static final String ENTITY_MANAGER_KEY
protected static final String TRANSACTION_MANAGER_KEY
protected EntityConfiguration entityConfiguration
protected StreamingTransactionCapableUtil transUtil
@Autowired protected List<javax.persistence.EntityManager> entityManagers
public boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public void stop(Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
public void start()
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public int getPhase()
getPhase
in interface org.springframework.context.Phased
getPhase
in interface org.springframework.context.SmartLifecycle
protected void initializeEntityManagerCache()
public boolean validateEntityClassName(String entityClassName)
PersistenceService
validateEntityClassName
in interface PersistenceService
public javax.persistence.EntityManager identifyEntityManager(Class entityClass)
PersistenceService
EntityManager
for the given entityClass, using the default targetModeType of TargetModeType.SANDBOX
identifyEntityManager
in interface PersistenceService
EntityManager
public javax.persistence.EntityManager identifyEntityManager(Class entityClass, TargetModeType targetModeType)
PersistenceService
EntityManager
for the given entityClass and targetModeTypeidentifyEntityManager
in interface PersistenceService
EntityManager
public org.springframework.transaction.PlatformTransactionManager identifyTransactionManager(String className, TargetModeType targetModeType)
PersistenceService
PlatformTransactionManager
for the given className and targetModeTypeidentifyTransactionManager
in interface PersistenceService
PlatformTransactionManager
public javax.persistence.EntityManager identifyDefaultEntityManager(TargetModeType targetModeType)
PersistenceService
EntityManager
for the given targetModeType
NOTE: This assumes that the EntityManager
is based on blPUidentifyDefaultEntityManager
in interface PersistenceService
EntityManager
public javax.persistence.EntityManager getEntityManager(Map<String,Object> managerMap)
PersistenceService
EntityManager
from the provided managerMapgetEntityManager
in interface PersistenceService
EntityManager
public org.springframework.transaction.PlatformTransactionManager identifyDefaultTransactionManager(TargetModeType targetModeType)
PersistenceService
PlatformTransactionManager
for the given targetModeType
NOTE: This assumes that the PlatformTransactionManager
is based on blPUidentifyDefaultTransactionManager
in interface PersistenceService
PlatformTransactionManager
public org.springframework.transaction.PlatformTransactionManager getTransactionManager(Map<String,Object> managerMap)
PersistenceService
PlatformTransactionManager
from the provided managerMapgetTransactionManager
in interface PersistenceService
PlatformTransactionManager
public Class<?> getCeilingImplClassFromEntityManagers(String className)
PersistenceService
EntityManager
. If
this is not found in the entity managers, this returns nullgetCeilingImplClassFromEntityManagers
in interface PersistenceService
Copyright © 2022. All rights reserved.