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 booleanprotected Booleanprotected org.springframework.context.ApplicationEventPublisherFields 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 voidprotected voiddoCommit(org.springframework.transaction.support.DefaultTransactionStatus status) protected Objectprotected voiddoRollback(org.springframework.transaction.support.DefaultTransactionStatus status) booleanvoidsetLogEvents(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, shouldCommitOnGlobalRollbackOnlyMethods 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, useSavepointForNestedTransactionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.transaction.ConfigurableTransactionManager
addListenerMethods 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:
doGetTransactionin classorg.springframework.orm.jpa.JpaTransactionManager
-
doBegin
protected void doBegin(Object transaction, org.springframework.transaction.TransactionDefinition definition) - Overrides:
doBeginin classorg.springframework.orm.jpa.JpaTransactionManager
-
doCommit
protected void doCommit(org.springframework.transaction.support.DefaultTransactionStatus status) - Overrides:
doCommitin classorg.springframework.orm.jpa.JpaTransactionManager
-
doRollback
protected void doRollback(org.springframework.transaction.support.DefaultTransactionStatus status) - Overrides:
doRollbackin classorg.springframework.orm.jpa.JpaTransactionManager
-
getLogEvents
-
setLogEvents
-
isEnabled
public boolean isEnabled()
-