@Override @Nullable public String getName() { return this.targetDefinition.getName(); }
@Override @Nullable public String getName() { return this.targetDefinition.getName(); }
@Override public TransactionStatus getTransaction(@Nullable TransactionDefinition def) throws TransactionException { if (invoked) { throw new IllegalStateException("getTransaction should not get invoked more than once"); } invoked = true; if (!(def.getName().contains(DerivedTestBean.class.getName()) && def.getName().contains("setAge"))) { throw new IllegalStateException( "transaction name should contain class and method name: " + def.getName()); } return ts; } @Override
/** * Copy constructor. Definition can be modified through bean property setters. * @see #setPropagationBehavior * @see #setIsolationLevel * @see #setTimeout * @see #setReadOnly * @see #setName */ public DefaultTransactionDefinition(TransactionDefinition other) { this.propagationBehavior = other.getPropagationBehavior(); this.isolationLevel = other.getIsolationLevel(); this.timeout = other.getTimeout(); this.readOnly = other.isReadOnly(); this.name = other.getName(); }
if (this.weblogicUserTransactionAvailable && definition.getName() != null) { try { if (timeout > TransactionDefinition.TIMEOUT_DEFAULT) { this.beginWithNameAndTimeoutMethod.invoke(txObject.getUserTransaction(), definition.getName(), timeout); this.beginWithNameMethod.invoke(txObject.getUserTransaction(), definition.getName());
/** * Copy constructor. Definition can be modified through bean property setters. * @see #setPropagationBehavior * @see #setIsolationLevel * @see #setTimeout * @see #setReadOnly * @see #setName */ public DefaultTransactionDefinition(TransactionDefinition other) { this.propagationBehavior = other.getPropagationBehavior(); this.isolationLevel = other.getIsolationLevel(); this.timeout = other.getTimeout(); this.readOnly = other.isReadOnly(); this.name = other.getName(); }
if (this.weblogicUserTransactionAvailable && definition.getName() != null) { try { if (timeout > TransactionDefinition.TIMEOUT_DEFAULT) { this.beginWithNameAndTimeoutMethod.invoke(txObject.getUserTransaction(), definition.getName(), timeout); this.beginWithNameMethod.invoke(txObject.getUserTransaction(), definition.getName());
/** * Initialize transaction synchronization as appropriate. */ protected void prepareSynchronization(DefaultTransactionStatus status, TransactionDefinition definition) { if (status.isNewSynchronization()) { TransactionSynchronizationManager.setActualTransactionActive(status.hasTransaction()); TransactionSynchronizationManager.setCurrentTransactionIsolationLevel( definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT ? definition.getIsolationLevel() : null); TransactionSynchronizationManager.setCurrentTransactionReadOnly(definition.isReadOnly()); TransactionSynchronizationManager.setCurrentTransactionName(definition.getName()); TransactionSynchronizationManager.initSynchronization(); } }
SuspendedResourcesHolder suspendedResources = suspend(null); if (debugEnabled) { logger.debug("Creating new transaction with name [" + definition.getName() + "]: " + definition);
logger.debug("Creating new transaction with name [" + definition.getName() + "]: " + definition);
/** * Initialize transaction synchronization as appropriate. */ protected void prepareSynchronization(DefaultTransactionStatus status, TransactionDefinition definition) { if (status.isNewSynchronization()) { TransactionSynchronizationManager.setActualTransactionActive(status.hasTransaction()); TransactionSynchronizationManager.setCurrentTransactionIsolationLevel( definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT ? definition.getIsolationLevel() : null); TransactionSynchronizationManager.setCurrentTransactionReadOnly(definition.isReadOnly()); TransactionSynchronizationManager.setCurrentTransactionName(definition.getName()); TransactionSynchronizationManager.initSynchronization(); } }
SuspendedResourcesHolder suspendedResources = suspend(null); if (debugEnabled) { logger.debug("Creating new transaction with name [" + definition.getName() + "]: " + definition);
logger.debug("Creating new transaction with name [" + definition.getName() + "]: " + definition);
public class HibernateExtendedJpaDialect extends HibernateJpaDialect { @Override public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException { Session session = (Session) entityManager.getDelegate(); DataSourceUtils.prepareConnectionForTransaction(session.connection(), definition); entityManager.getTransaction().begin(); return prepareTransaction(entityManager, definition.isReadOnly(), definition.getName()); } }
@Override @Nullable public String getName() { return this.targetDefinition.getName(); }
@Override @Nullable public String getName() { return this.targetDefinition.getName(); }
@Aspect public class AspectAroundTransactions() { @Pointcut("execution(* org.springframework.*.AbstractPlatformTransactionManager.getTransaction(..))" ) public void newTransaction() {} @Before("newTransaction() && args(transactionDefinition,..)") public void beforeStartOfTransaction(TransactionDefinition transactionDefinition) { // here goes you code long start = System.nanoTime(); System.out.println("Transaction " + transactionDefinition.getName() + " started at " + start ); } }
public CustomizableRollbackTransactionAttribute(TransactionDefinition other) { super(); setPropagationBehavior(other.getPropagationBehavior()); setIsolationLevel(other.getIsolationLevel()); setTimeout(other.getTimeout()); setReadOnly(other.isReadOnly()); setName(other.getName()); }