本文整理汇总了Java中org.springframework.transaction.support.DefaultTransactionStatus.isNewSynchronization方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTransactionStatus.isNewSynchronization方法的具体用法?Java DefaultTransactionStatus.isNewSynchronization怎么用?Java DefaultTransactionStatus.isNewSynchronization使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.transaction.support.DefaultTransactionStatus
的用法示例。
在下文中一共展示了DefaultTransactionStatus.isNewSynchronization方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commitTransactionAfterReturning
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
/**
* @see org.springframework.transaction.interceptor.TransactionAspectSupport#doCommitTransactionAfterReturning(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo)
*/
@Override
protected void commitTransactionAfterReturning(TransactionInfo txInfo) {
// using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass
if (logger.isDebugEnabled()) {
if (txInfo != null) {
TransactionStatus txStatus = txInfo.getTransactionStatus();
if (txStatus != null) {
if (txStatus.isNewTransaction()) {
LOG.debug("committing explicit transaction for " + txInfo.getJoinpointIdentification());
}
else {
if (txStatus instanceof DefaultTransactionStatus) {
DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus;
if (dtxStatus.isNewSynchronization()) {
LOG.debug("committing implicit transaction for " + txInfo.getJoinpointIdentification());
}
}
}
}
}
}
super.commitTransactionAfterReturning(txInfo);
}
示例2: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status)
{
MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction();
if (LOG.isDebugEnabled())
{
LOG.debug("Rollback transaction [{}]", transaction.getId());
}
DefaultTransactionStatus jpaTransactionStatus = new DefaultTransactionStatus(
transaction.getDataSourceTransaction(), status.isNewTransaction(), status.isNewSynchronization(),
status.isReadOnly(), status.isDebug(), status.getSuspendedResources());
if (!status.isReadOnly())
{
transactionListeners.forEach(j -> j.rollbackTransaction(transaction.getId()));
}
super.doRollback(jpaTransactionStatus);
}
示例3: run
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
public void run() {
DefaultTransactionStatus status = prepareTransactionStatus(
this.definition, (this.actualTransaction ? this : null),
this.newTransaction, this.newSynchronization, this.debug, null);
try {
this.result = this.callback.doInTransaction(status);
triggerBeforeCommit(status);
}
catch (Throwable ex) {
this.exception = ex;
uowManager.setRollbackOnly();
}
finally {
if (status.isLocalRollbackOnly()) {
if (status.isDebug()) {
logger.debug("Transactional code has requested rollback");
}
uowManager.setRollbackOnly();
}
triggerBeforeCompletion(status);
if (status.isNewSynchronization()) {
List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations();
TransactionSynchronizationManager.clear();
if (!synchronizations.isEmpty()) {
uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
}
}
}
}
示例4: createTransactionIfNecessary
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
/**
* @see org.springframework.transaction.interceptor.TransactionAspectSupport#createTransactionIfNecessary(java.lang.reflect.Method,
* java.lang.Class)
*/
@Override
protected TransactionInfo createTransactionIfNecessary(Method method, Class targetClass) {
TransactionInfo txInfo = super.createTransactionIfNecessary(method, targetClass);
// using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass
if (logger.isDebugEnabled()) {
if (txInfo != null) {
TransactionStatus txStatus = txInfo.getTransactionStatus();
if (txStatus != null) {
if (txStatus.isNewTransaction()) {
LOG.debug("creating explicit transaction for " + txInfo.getJoinpointIdentification());
}
else {
if (txStatus instanceof DefaultTransactionStatus) {
DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus;
if (dtxStatus.isNewSynchronization()) {
LOG.debug("creating implicit transaction for " + txInfo.getJoinpointIdentification());
}
}
}
}
}
}
return txInfo;
}
示例5: completeTransactionAfterThrowing
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
/**
* @see org.springframework.transaction.interceptor.TransactionAspectSupport#doCloseTransactionAfterThrowing(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo,
* java.lang.Throwable)
*/
@Override
protected void completeTransactionAfterThrowing(TransactionInfo txInfo, Throwable ex) {
if (txInfo.getTransactionAttribute().rollbackOn(ex)) {
LOG.fatal("Exception caught by Transaction Interceptor, this will cause a rollback at the end of the transaction.", ex);
}
// using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass
if (logger.isDebugEnabled()) {
if (txInfo != null) {
TransactionStatus txStatus = txInfo.getTransactionStatus();
if (txStatus != null) {
if (txStatus.isNewTransaction()) {
LOG.debug("closing explicit transaction for " + txInfo.getJoinpointIdentification());
}
else {
if (txStatus instanceof DefaultTransactionStatus) {
DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus;
if (dtxStatus.isNewSynchronization()) {
LOG.debug("closing implicit transaction for " + txInfo.getJoinpointIdentification());
}
}
}
}
}
}
super.completeTransactionAfterThrowing(txInfo, ex);
}
示例6: prepareSynchronization
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void prepareSynchronization(DefaultTransactionStatus status, TransactionDefinition definition) {
super.prepareSynchronization(status, definition);
if (status.isNewSynchronization() &&
definition.getPropagationBehavior() != TransactionDefinition.PROPAGATION_NOT_SUPPORTED) {
log.trace("Registering new session synchronization");
StorageSessionFactory sessionFactory = ContextHelper.get().beanForType(StorageSessionFactory.class);
StorageSession session = sessionFactory.create();
TransactionSynchronizationManager.registerSynchronization(
new SessionSynchronization(session, definition.getName()));
}
}
示例7: run
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
public void run() {
DefaultTransactionStatus status = prepareTransactionStatus(
this.definition, (this.actualTransaction ? this : null),
this.newTransaction, this.newSynchronization, this.debug, null);
try {
this.result = this.callback.doInTransaction(status);
triggerBeforeCommit(status);
}
catch (Throwable ex) {
this.exception = ex;
uowManager.setRollbackOnly();
}
finally {
if (status.isLocalRollbackOnly()) {
if (status.isDebug()) {
logger.debug("Transactional code has requested rollback");
}
uowManager.setRollbackOnly();
}
triggerBeforeCompletion(status);
if (status.isNewSynchronization()) {
List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations();
TransactionSynchronizationManager.clear();
if (!synchronizations.isEmpty()) {
uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
}
}
}
}
示例8: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status)
{
MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction();
if (LOG.isDebugEnabled())
{
LOG.debug("Commit transaction [{}]", transaction.getId());
}
DefaultTransactionStatus jpaTransactionStatus = new DefaultTransactionStatus(
transaction.getDataSourceTransaction(), status.isNewTransaction(), status.isNewSynchronization(),
status.isReadOnly(), status.isDebug(), status.getSuspendedResources());
if (!status.isReadOnly())
{
transactionListeners.forEach(j -> j.commitTransaction(transaction.getId()));
}
try
{
super.doCommit(jpaTransactionStatus);
}
catch (TransactionException e)
{
throw translateTransactionException(e);
}
if (!status.isReadOnly())
{
transactionListeners.forEach(j -> j.afterCommitTransaction(transaction.getId()));
}
}
示例9: doSetRollbackOnly
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status)
{
MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction();
DefaultTransactionStatus jpaTransactionStatus = new DefaultTransactionStatus(
transaction.getDataSourceTransaction(), status.isNewTransaction(), status.isNewSynchronization(),
status.isReadOnly(), status.isDebug(), status.getSuspendedResources());
super.doSetRollbackOnly(jpaTransactionStatus);
}
示例10: completeTransactionAfterThrowing
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
/**
* @see org.springframework.transaction.interceptor.TransactionAspectSupport#doCloseTransactionAfterThrowing(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo,
* java.lang.Throwable)
*/
@Override
protected void completeTransactionAfterThrowing(TransactionInfo txInfo, Throwable ex) {
LOG.fatal( "Exception caught by Transaction Interceptor, this will cause a rollback at the end of the transaction.", ex );
// using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass
if (logger.isDebugEnabled()) {
if (txInfo != null) {
TransactionStatus txStatus = txInfo.getTransactionStatus();
if (txStatus != null) {
if (txStatus.isNewTransaction()) {
LOG.debug("closing explicit transaction for " + txInfo.getJoinpointIdentification());
}
else {
if (txStatus instanceof DefaultTransactionStatus) {
DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus;
if (dtxStatus.isNewSynchronization()) {
LOG.debug("closing implicit transaction for " + txInfo.getJoinpointIdentification());
}
}
}
}
}
}
super.completeTransactionAfterThrowing(txInfo, ex);
}
示例11: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
protected void doCommit(DefaultTransactionStatus status) {
ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status
.getTransaction();
try {
super.doCommit(new DefaultTransactionStatus(actualTransactionObject
.getHibernateTransactionObject(), status
.isNewTransaction(), status.isNewSynchronization(), status
.isReadOnly(), status.isDebug(), status
.getSuspendedResources()));
} catch (TransactionException ex) {
if (isRollbackOnCommitFailure()) {
logger.debug("Failed to commit db resource, rethrowing", ex);
// If we are to rollback on commit failure, just rethrow the
// exception - this will cause a rollback to be performed on
// both resources.
throw ex;
} else {
logger
.warn("Failed to commit and resource is rollbackOnCommit not set -"
+ " proceeding to commit ldap resource.");
}
}
ldapManagerDelegate.doCommit(new DefaultTransactionStatus(
actualTransactionObject.getLdapTransactionObject(), status
.isNewTransaction(), status.isNewSynchronization(),
status.isReadOnly(), status.isDebug(), status
.getSuspendedResources()));
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:31,代码来源:ContextSourceAndHibernateTransactionManager.java
示例12: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
protected void doRollback(DefaultTransactionStatus status) {
ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status
.getTransaction();
super.doRollback(new DefaultTransactionStatus(actualTransactionObject
.getHibernateTransactionObject(), status.isNewTransaction(),
status.isNewSynchronization(), status.isReadOnly(), status
.isDebug(), status.getSuspendedResources()));
ldapManagerDelegate.doRollback(new DefaultTransactionStatus(
actualTransactionObject.getLdapTransactionObject(), status
.isNewTransaction(), status.isNewSynchronization(),
status.isReadOnly(), status.isDebug(), status
.getSuspendedResources()));
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:15,代码来源:ContextSourceAndHibernateTransactionManager.java
示例13: doCommit
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
protected void doCommit(DefaultTransactionStatus status) {
ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status
.getTransaction();
try {
super.doCommit(new DefaultTransactionStatus(actualTransactionObject
.getDataSourceTransactionObject(), status
.isNewTransaction(), status.isNewSynchronization(), status
.isReadOnly(), status.isDebug(), status
.getSuspendedResources()));
} catch (TransactionException ex) {
if (isRollbackOnCommitFailure()) {
logger.debug("Failed to commit db resource, rethrowing", ex);
// If we are to rollback on commit failure, just rethrow the
// exception - this will cause a rollback to be performed on
// both resources.
throw ex;
} else {
logger
.warn("Failed to commit and resource is rollbackOnCommit not set -"
+ " proceeding to commit ldap resource.");
}
}
ldapManagerDelegate.doCommit(new DefaultTransactionStatus(
actualTransactionObject.getLdapTransactionObject(), status
.isNewTransaction(), status.isNewSynchronization(),
status.isReadOnly(), status.isDebug(), status
.getSuspendedResources()));
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:31,代码来源:ContextSourceAndDataSourceTransactionManager.java
示例14: doRollback
import org.springframework.transaction.support.DefaultTransactionStatus; //导入方法依赖的package包/类
protected void doRollback(DefaultTransactionStatus status) {
ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status
.getTransaction();
super.doRollback(new DefaultTransactionStatus(actualTransactionObject
.getDataSourceTransactionObject(), status.isNewTransaction(),
status.isNewSynchronization(), status.isReadOnly(), status
.isDebug(), status.getSuspendedResources()));
ldapManagerDelegate.doRollback(new DefaultTransactionStatus(
actualTransactionObject.getLdapTransactionObject(), status
.isNewTransaction(), status.isNewSynchronization(),
status.isReadOnly(), status.isDebug(), status
.getSuspendedResources()));
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:15,代码来源:ContextSourceAndDataSourceTransactionManager.java