Package org.springframework.transaction.jta

Examples of org.springframework.transaction.jta.JtaTransactionManager


    session.close();
    sessionControl.setReturnValue(null, 1);
    sfControl.replay();
    sessionControl.replay();

    JtaTransactionManager tm = new JtaTransactionManager(ut);
    TransactionTemplate tt = new TransactionTemplate(tm);
    tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
    final TransactionTemplate tt2 = new TransactionTemplate(tm);
    tt2.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
View Full Code Here


    thread.join();

    assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

    TransactionTemplate tt = new TransactionTemplate(new JtaTransactionManager(tm));
    tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
    tt.setReadOnly(true);
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive());
View Full Code Here

          return null;
        }
      });
    }

    TransactionTemplate tt = new TransactionTemplate(new JtaTransactionManager(ut));
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        for (int i = 2; i < 5; i++) {
          ht.executeFind(new HibernateCallback() {
            public Object doInHibernate(org.hibernate.Session sess) {
View Full Code Here

        tcm = (TransactionContextManager) tcmfb.getObject();
        GeronimoTransactionManagerFactoryBean gtmfb = new GeronimoTransactionManagerFactoryBean();
        gtmfb.setTransactionContextManager(tcm);
        gtmfb.afterPropertiesSet();
        tm = (TransactionManager) gtmfb.getObject();
        tt = new TransactionTemplate(new JtaTransactionManager((UserTransaction) tm));
    }
View Full Code Here

        TransactionContextManager tcm = (TransactionContextManager) tcmfb.getObject();
        GeronimoTransactionManagerFactoryBean gtmfb = new GeronimoTransactionManagerFactoryBean();
        gtmfb.setTransactionContextManager(tcm);
        gtmfb.afterPropertiesSet();
        TransactionManager tm = (TransactionManager) gtmfb.getObject();
        tt = new TransactionTemplate(new JtaTransactionManager((UserTransaction) tm));
      
        BrokerFactoryBean bfb = new BrokerFactoryBean(new ClassPathResource("org/apache/servicemix/jbi/nmr/flow/jca/broker.xml"));
        bfb.afterPropertiesSet();
        broker = bfb.getBroker();
        broker.start();
View Full Code Here

      tm.commit();
      tmControl.setVoidCallable(1);
    }
    tmControl.replay();

    JtaTransactionManager ptm = new JtaTransactionManager();
    ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
    if (defaultUt) {
      jndiTemplate.addObject("java:comp/UserTransaction", ut);
    }
    jndiTemplate.addObject(tmName, tm);
    ptm.setJndiTemplate(jndiTemplate);
    ptm.afterPropertiesSet();

    if (tmFound) {
      assertEquals(tm, ptm.getTransactionManager());
    }
    else {
      assertNull(ptm.getTransactionManager());
    }

    if (defaultUt) {
      assertEquals(ut, ptm.getUserTransaction());
    }
    else {
      assertTrue(ptm.getUserTransaction() instanceof UserTransactionAdapter);
      UserTransactionAdapter uta = (UserTransactionAdapter) ptm.getUserTransaction();
      assertEquals(tm, uta.getTransactionManager());
    }

    TransactionTemplate tt = new TransactionTemplate(ptm);
    assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
View Full Code Here

    utControl.replay();

    MockControl tmControl = MockControl.createControl(TransactionManager.class);
    TransactionManager tm = (TransactionManager) tmControl.getMock();

    JtaTransactionManager ptm = new JtaTransactionManager();
    ptm.setUserTransactionName("jndi-ut");
    ptm.setTransactionManagerName("jndi-tm");
    ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
    jndiTemplate.addObject("jndi-ut", ut);
    jndiTemplate.addObject("jndi-tm", tm);
    ptm.setJndiTemplate(jndiTemplate);
    ptm.afterPropertiesSet();

    assertEquals(ut, ptm.getUserTransaction());
    assertEquals(tm, ptm.getTransactionManager());

    TransactionTemplate tt = new TransactionTemplate(ptm);
    assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
    assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
    tt.execute(new TransactionCallbackWithoutResult() {
View Full Code Here

    ut2Control.setVoidCallable(1);
    ut2.commit();
    ut2Control.setVoidCallable(1);
    ut2Control.replay();

    JtaTransactionManager ptm = new JtaTransactionManager();
    ptm.setJndiTemplate(new ExpectedLookupTemplate("java:comp/UserTransaction", ut));
    ptm.setCacheUserTransaction(false);
    ptm.afterPropertiesSet();

    assertEquals(ut, ptm.getUserTransaction());

    TransactionTemplate tt = new TransactionTemplate(ptm);
    assertEquals(JtaTransactionManager.SYNCHRONIZATION_ALWAYS, ptm.getTransactionSynchronization());
    assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
    assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        // something transactional
        assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
        assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
      }
    });

    ptm.setJndiTemplate(new ExpectedLookupTemplate("java:comp/UserTransaction", ut2));
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        // something transactional
        assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
        assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
View Full Code Here

    synchControl.setVoidCallable(1);
    synch.afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK);
    synchControl.setVoidCallable(1);
    synchControl.replay();

    JtaTransactionManager ptm = newJtaTransactionManager(ut);
    TransactionTemplate tt = new TransactionTemplate(ptm);
    tt.setTimeout(10);
    tt.setName("txName");

    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
View Full Code Here

    synchControl.setVoidCallable(1);
    synch.afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK);
    synchControl.setVoidCallable(1);
    synchControl.replay();

    JtaTransactionManager ptm = newJtaTransactionManager(ut);
    TransactionTemplate tt = new TransactionTemplate(ptm);
    ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_ON_ACTUAL_TRANSACTION);
    tt.setTimeout(10);
    assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
    tt.execute(new TransactionCallbackWithoutResult() {
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
View Full Code Here

TOP

Related Classes of org.springframework.transaction.jta.JtaTransactionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.