Example usage for org.springframework.transaction.support AbstractPlatformTransactionManager SYNCHRONIZATION_ALWAYS

List of usage examples for org.springframework.transaction.support AbstractPlatformTransactionManager SYNCHRONIZATION_ALWAYS

Introduction

In this page you can find the example usage for org.springframework.transaction.support AbstractPlatformTransactionManager SYNCHRONIZATION_ALWAYS.

Prototype

int SYNCHRONIZATION_ALWAYS

To view the source code for org.springframework.transaction.support AbstractPlatformTransactionManager SYNCHRONIZATION_ALWAYS.

Click Source Link

Document

Always activate transaction synchronization, even for "empty" transactions that result from PROPAGATION_SUPPORTS with no existing backend transaction.

Usage

From source file:com.newmainsoftech.spray.slingong.datastore.Slim3PlatformTransactionManagerTest2.java

@Before
public void setUp() throws Throwable {
    gaeTestHelper.setUp();/* w w w .j av a 2  s .  c o m*/

    // Confirmations on Spring ApplicationContext status --------------------------------------
    Assert.assertNotNull(applicationContext);

    final String annotationBeanConfigurerAspectBeanId = "annotationBeanConfigurerAspect";
    Assert.assertTrue(applicationContext.containsBean(annotationBeanConfigurerAspectBeanId));
    Assert.assertNotNull(applicationContext.getBean(annotationBeanConfigurerAspectBeanId));

    final String slim3PlatformTransactionManagerBeanId = "txManager";
    Assert.assertTrue(applicationContext.containsBean(slim3PlatformTransactionManagerBeanId));
    Assert.assertEquals(applicationContext.getBean(slim3PlatformTransactionManagerBeanId),
            slim3PlatformTransactionManager);
    Assert.assertTrue(slim3PlatformTransactionManager instanceof Slim3PlatformTransactionManager);
    Assert.assertEquals(AbstractPlatformTransactionManager.SYNCHRONIZATION_ALWAYS,
            slim3PlatformTransactionManager.getTransactionSynchronization());
    Assert.assertFalse(slim3PlatformTransactionManager.isNestedTransactionAllowed());

    final String annotationTransactionAspectBeanId = "annotationTransactionAspect";
    Assert.assertTrue(applicationContext.containsBean(annotationTransactionAspectBeanId));
    Assert.assertEquals(applicationContext.getBean(annotationTransactionAspectBeanId),
            annotationTransactionAspect);

    final String annotationTransactionOnStaticMethodAspectBeanId = "annotationTransactionOnStaticMethodAspect";
    Assert.assertTrue(applicationContext.containsBean(annotationTransactionOnStaticMethodAspectBeanId));
    Assert.assertNotNull(applicationContext.getBean(annotationTransactionOnStaticMethodAspectBeanId));
    // ----------------------------------------------------------------------------------------

    logGlobalTransactionStatus();
}

From source file:com.newmainsoftech.spray.slingong.datastore.Slim3PlatformTransactionManagerTest.java

@Before
public void setUp() throws Throwable {
    gaeTestHelper.setUp();/*from  w ww. java2  s .c o  m*/

    // Confirmations on Spring ApplicationContext status --------------------------------------
    Assert.assertNotNull(applicationContext);
    final String annotationBeanConfigurerAspectBeanId = "annotationBeanConfigurerAspect";
    Assert.assertTrue(applicationContext.containsBean(annotationBeanConfigurerAspectBeanId));
    Assert.assertNotNull(applicationContext.getBean(annotationBeanConfigurerAspectBeanId));

    final String slim3PlatformTransactionManagerBeanId = "txManager";
    Assert.assertTrue(applicationContext.containsBean(slim3PlatformTransactionManagerBeanId));
    Assert.assertEquals(applicationContext.getBean(slim3PlatformTransactionManagerBeanId),
            slim3PlatformTransactionManager);
    Assert.assertTrue(slim3PlatformTransactionManager instanceof Slim3PlatformTransactionManager);
    Assert.assertEquals(AbstractPlatformTransactionManager.SYNCHRONIZATION_ALWAYS,
            slim3PlatformTransactionManager.getTransactionSynchronization());
    Assert.assertFalse(slim3PlatformTransactionManager.isNestedTransactionAllowed());

    final String annotationTransactionAspectBeanId = "annotationTransactionAspect";
    Assert.assertTrue(applicationContext.containsBean(annotationTransactionAspectBeanId));
    Assert.assertEquals(applicationContext.getBean(annotationTransactionAspectBeanId),
            annotationTransactionAspect);
    final String annotationTransactionOnStaticMethodAspectBeanId = "annotationTransactionOnStaticMethodAspect";
    Assert.assertTrue(applicationContext.containsBean(annotationTransactionOnStaticMethodAspectBeanId));
    Assert.assertNotNull(applicationContext.getBean(annotationTransactionOnStaticMethodAspectBeanId));
    // ----------------------------------------------------------------------------------------

    mockedSlim3TxMangerInOrder = Mockito.inOrder(slim3PlatformTransactionManager);

    // Extracting JCL (Apache Jakarta Common Logging) logger debug setting of Slim3PlatformTransactionManager.class
    debugEnabledInAbstractPlatformTransactionManager = LogFactory.getLog(Slim3PlatformTransactionManager.class)
            .isDebugEnabled();
    /* org.springframework.transaction.support.AbstractPlatformTransactionManager (what is super 
     * class of Slim3PlatformTransactionManager class) uses logger's debug flag as one of arguments 
     * in some calls as you see in its getTransaction method code and the signatures of the 
     * following methods of AbstractPlatformTransactionManager:
     *     handleExistingTransaction
     *     newTransactionStatus
     *     prepareTransactionStatus
     * 
     * I also confirmed that SLF4J's LogFactory.getLog( Slim3PlatformTransactionManager.class).isDebugEnabled() 
     * returned the same value.
     */

    logGlobalTransactionStatus();
}