Class LifecycleAwareJpaTransactionManager
java.lang.Object
org.springframework.transaction.support.AbstractPlatformTransactionManager
org.springframework.orm.jpa.JpaTransactionManager
org.broadleafcommerce.common.persistence.transaction.LifecycleAwareJpaTransactionManager
- All Implemented Interfaces:
Serializable
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.InitializingBean
,org.springframework.transaction.ConfigurableTransactionManager
,org.springframework.transaction.PlatformTransactionManager
,org.springframework.transaction.support.ResourceTransactionManager
,org.springframework.transaction.TransactionManager
public class LifecycleAwareJpaTransactionManager
extends org.springframework.orm.jpa.JpaTransactionManager
A customized
JpaTransactionManager
that will send Spring events at key lifecycle points during a transaction.
Listeners can perform additional work at the time of these events, such as logging (any persistence related activity
should be avoided). Event publishing attempts to be safe and will log exceptions without bubbling them. Event publishing
is disabled by default, but may be enabled by using the 'transaction.lifecycle.events.enabled=true' property, or by setting
the logEvents
property on a case-by-case basis.- Author:
- Jeff Fischer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected Boolean
protected org.springframework.context.ApplicationEventPublisher
Fields inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
logger, SYNCHRONIZATION_ALWAYS, SYNCHRONIZATION_NEVER, SYNCHRONIZATION_ON_ACTUAL_TRANSACTION
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
doCommit
(org.springframework.transaction.support.DefaultTransactionStatus status) protected Object
protected void
doRollback
(org.springframework.transaction.support.DefaultTransactionStatus status) boolean
void
setLogEvents
(Boolean logEvents) Methods inherited from class org.springframework.orm.jpa.JpaTransactionManager
afterPropertiesSet, closeEntityManagerAfterFailedBegin, createEntityManagerForTransaction, doCleanupAfterCompletion, doResume, doSetRollbackOnly, doSuspend, getDataSource, getEntityManagerFactory, getJpaDialect, getJpaPropertyMap, getPersistenceUnitName, getResourceFactory, isExistingTransaction, obtainEntityManagerFactory, setBeanFactory, setDataSource, setEntityManagerFactory, setEntityManagerInitializer, setJpaDialect, setJpaProperties, setJpaPropertyMap, setPersistenceUnitName, shouldCommitOnGlobalRollbackOnly
Methods inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
commit, determineTimeout, getDefaultTimeout, getTransaction, getTransactionExecutionListeners, getTransactionSynchronization, invokeAfterCompletion, isFailEarlyOnGlobalRollbackOnly, isGlobalRollbackOnParticipationFailure, isNestedTransactionAllowed, isRollbackOnCommitFailure, isValidateExistingTransaction, prepareForCommit, prepareSynchronization, registerAfterCompletionWithExistingTransaction, resume, rollback, setDefaultTimeout, setFailEarlyOnGlobalRollbackOnly, setGlobalRollbackOnParticipationFailure, setNestedTransactionAllowed, setRollbackOnCommitFailure, setTransactionExecutionListeners, setTransactionSynchronization, setTransactionSynchronizationName, setValidateExistingTransaction, suspend, triggerBeforeCommit, triggerBeforeCompletion, useSavepointForNestedTransaction
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.transaction.ConfigurableTransactionManager
addListener
Methods inherited from interface org.springframework.transaction.PlatformTransactionManager
commit, getTransaction, rollback
-
Field Details
-
defaultLogEvents
@Value("${transaction.lifecycle.events.enabled:false}") protected boolean defaultLogEvents -
logEvents
-
publisher
@Autowired protected org.springframework.context.ApplicationEventPublisher publisher
-
-
Constructor Details
-
LifecycleAwareJpaTransactionManager
public LifecycleAwareJpaTransactionManager()
-
-
Method Details
-
doGetTransaction
- Overrides:
doGetTransaction
in classorg.springframework.orm.jpa.JpaTransactionManager
-
doBegin
protected void doBegin(Object transaction, org.springframework.transaction.TransactionDefinition definition) - Overrides:
doBegin
in classorg.springframework.orm.jpa.JpaTransactionManager
-
doCommit
protected void doCommit(org.springframework.transaction.support.DefaultTransactionStatus status) - Overrides:
doCommit
in classorg.springframework.orm.jpa.JpaTransactionManager
-
doRollback
protected void doRollback(org.springframework.transaction.support.DefaultTransactionStatus status) - Overrides:
doRollback
in classorg.springframework.orm.jpa.JpaTransactionManager
-
getLogEvents
-
setLogEvents
-
isEnabled
public boolean isEnabled()
-