List of usage examples for org.springframework.transaction.jta JtaTransactionManager JtaTransactionManager
public JtaTransactionManager(UserTransaction userTransaction, TransactionManager transactionManager)
From source file:org.apache.servicemix.transaction.GeronimoPlatformTransactionManager.java
public GeronimoPlatformTransactionManager() throws XAException { platformTransactionManager = new JtaTransactionManager(this, this); registerTransactionAssociationListener(); }
From source file:org.apache.servicemix.transaction.GeronimoPlatformTransactionManager.java
public GeronimoPlatformTransactionManager(int defaultTransactionTimeoutSeconds) throws XAException { super(defaultTransactionTimeoutSeconds); platformTransactionManager = new JtaTransactionManager(this, this); registerTransactionAssociationListener(); }
From source file:org.csc.phynixx.spring.integration.config.AtomikosJtaConfiguration.java
@Bean public PlatformTransactionManager platformTransactionManager() throws Throwable { UserTransaction userTransaction = this.userTransaction(); TransactionManager transactionManager = this.transactionManager(); return new JtaTransactionManager(userTransaction, transactionManager); }
From source file:org.apache.servicemix.transaction.GeronimoPlatformTransactionManager.java
public GeronimoPlatformTransactionManager(int defaultTransactionTimeoutSeconds, TransactionLog transactionLog) throws XAException { super(defaultTransactionTimeoutSeconds, transactionLog); platformTransactionManager = new JtaTransactionManager(this, this); registerTransactionAssociationListener(); }
From source file:org.apache.servicemix.transaction.GeronimoPlatformTransactionManager.java
public GeronimoPlatformTransactionManager(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException { super(defaultTransactionTimeoutSeconds, xidFactory, transactionLog); platformTransactionManager = new JtaTransactionManager(this, this); registerTransactionAssociationListener(); }
From source file:org.springsource.jta.etailer.store.config.PersistenceConfiguration.java
@Bean public PlatformTransactionManager platformTransactionManager() throws Throwable { UserTransaction userTransaction = jtaConfiguration.userTransaction(); TransactionManager transactionManager = jtaConfiguration.transactionManager(); return new JtaTransactionManager(userTransaction, transactionManager); }
From source file:it.reply.orchestrator.config.PersistenceConfigTest.java
@Bean public PlatformTransactionManager transactionManager() { return new JtaTransactionManager(bitronixTransactionManager(), bitronixTransactionManager()); }
From source file:org.springsource.greenbeans.examples.edawithspring.etailer.store.StoreConfiguration.java
@Bean public PlatformTransactionManager transactionManager() throws Exception { return new JtaTransactionManager(this.userTransaction(), this.userTransactionManager()); }
From source file:com._4dconcept.springframework.data.marklogic.datasource.DatabaseConnectorJtaTransactionTest.java
private void doTestJtaTransactionWithPropagationRequiresNew(final boolean rollback, final boolean openOuterConnection, final boolean accessAfterResume, final boolean useTransactionAwareContentSource) throws Exception { given(transactionManager.suspend()).willReturn(transaction); if (rollback) { given(userTransaction.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE); } else {/* w w w.j a v a2s . c om*/ given(userTransaction.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE); } given(session.getTransactionMode()).willReturn(Session.TransactionMode.QUERY); final ContentSource dsToUse = useTransactionAwareContentSource ? new TransactionAwareContentSourceProxy(contentSource) : contentSource; JtaTransactionManager ptm = new JtaTransactionManager(userTransaction, transactionManager); final TransactionTemplate tt = new TransactionTemplate(ptm); tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(dsToUse)); assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) throws RuntimeException { assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(dsToUse)); assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive()); assertTrue("Is new transaction", status.isNewTransaction()); Session s = ContentSourceUtils.getSession(dsToUse); assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(dsToUse)); s.getTransactionMode(); ContentSourceUtils.releaseSession(s, dsToUse); s = ContentSourceUtils.getSession(dsToUse); assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(dsToUse)); if (!openOuterConnection) { ContentSourceUtils.releaseSession(s, dsToUse); } for (int i = 0; i < 5; i++) { tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) throws RuntimeException { assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(dsToUse)); assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive()); assertTrue("Is new transaction", status.isNewTransaction()); Session s = ContentSourceUtils.getSession(dsToUse); s.getTransactionMode(); assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(dsToUse)); ContentSourceUtils.releaseSession(s, dsToUse); s = ContentSourceUtils.getSession(dsToUse); assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(dsToUse)); ContentSourceUtils.releaseSession(s, dsToUse); } }); } if (rollback) { status.setRollbackOnly(); } if (accessAfterResume) { if (!openOuterConnection) { s = ContentSourceUtils.getSession(dsToUse); } assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(dsToUse)); s.getTransactionMode(); ContentSourceUtils.releaseSession(s, dsToUse); s = ContentSourceUtils.getSession(dsToUse); assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(dsToUse)); ContentSourceUtils.releaseSession(s, dsToUse); } else { if (openOuterConnection) { ContentSourceUtils.releaseSession(s, dsToUse); } } } }); assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(dsToUse)); assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); verify(userTransaction, times(6)).begin(); verify(transactionManager, times(5)).resume(transaction); if (rollback) { verify(userTransaction, times(5)).commit(); verify(userTransaction).rollback(); } else { verify(userTransaction, times(6)).commit(); } if (accessAfterResume && !openOuterConnection) { verify(session, times(7)).close(); } else { verify(session, times(6)).close(); } }
From source file:com._4dconcept.springframework.data.marklogic.datasource.DatabaseConnectorJtaTransactionTest.java
private void doTestJtaTransactionCommitWithNewTransactionWithinEmptyTransaction(final boolean requiresNew, boolean notSupported) throws Exception { if (notSupported) { given(userTransaction.getStatus()).willReturn(Status.STATUS_ACTIVE, Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE); given(transactionManager.suspend()).willReturn(transaction); } else {/* ww w . jav a 2 s .com*/ given(userTransaction.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE); } final ContentSource contentSource = mock(ContentSource.class); final Session session1 = mock(Session.class); final Session session2 = mock(Session.class); given(contentSource.newSession()).willReturn(session1, session2); final JtaTransactionManager ptm = new JtaTransactionManager(userTransaction, transactionManager); TransactionTemplate tt = new TransactionTemplate(ptm); tt.setPropagationBehavior(notSupported ? TransactionDefinition.PROPAGATION_NOT_SUPPORTED : TransactionDefinition.PROPAGATION_SUPPORTS); assertFalse(TransactionSynchronizationManager.isSynchronizationActive()); tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertSame(session1, ContentSourceUtils.getSession(contentSource)); assertSame(session1, ContentSourceUtils.getSession(contentSource)); TransactionTemplate tt2 = new TransactionTemplate(ptm); tt2.setPropagationBehavior(requiresNew ? TransactionDefinition.PROPAGATION_REQUIRES_NEW : TransactionDefinition.PROPAGATION_REQUIRED); tt2.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); assertSame(session2, ContentSourceUtils.getSession(contentSource)); assertSame(session2, ContentSourceUtils.getSession(contentSource)); } }); assertTrue(TransactionSynchronizationManager.isSynchronizationActive()); assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); assertFalse(TransactionSynchronizationManager.isActualTransactionActive()); assertSame(session1, ContentSourceUtils.getSession(contentSource)); } }); assertFalse(TransactionSynchronizationManager.isSynchronizationActive()); verify(userTransaction).begin(); verify(userTransaction).commit(); if (notSupported) { verify(transactionManager).resume(transaction); } verify(session2).close(); verify(session1).close(); }