Java Code Examples for org.springframework.transaction.jta.JtaTransactionManager#setUserTransaction()
The following examples show how to use
org.springframework.transaction.jta.JtaTransactionManager#setUserTransaction() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataSourceConfig.java From mybatis.flying with Apache License 2.0 | 6 votes |
@Bean(name = "springTransactionManager") // 用户数据源的事务管理器 public JtaTransactionManager accountTxManager() { UserTransactionManager atomikosTransactionManager = new UserTransactionManager(); atomikosTransactionManager.setForceShutdown(true); UserTransaction atomikosUserTransaction = new UserTransactionImp(); try { atomikosUserTransaction.setTransactionTimeout(300); } catch (SystemException e) { } JtaTransactionManager springTransactionManager = new org.springframework.transaction.jta.JtaTransactionManager(); springTransactionManager.setTransactionManager(atomikosTransactionManager); springTransactionManager.setUserTransaction(atomikosUserTransaction); springTransactionManager.setAllowCustomIsolationLevels(true); return springTransactionManager; }
Example 2
Source File: HibernateTransactionManagerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testSetJtaTransactionManager() throws Exception { DataSource ds = mock(DataSource.class); TransactionManager tm = mock(TransactionManager.class); UserTransaction ut = mock(UserTransaction.class); TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class); JtaTransactionManager jtm = new JtaTransactionManager(); jtm.setTransactionManager(tm); jtm.setUserTransaction(ut); jtm.setTransactionSynchronizationRegistry(tsr); LocalSessionFactoryBuilder lsfb = new LocalSessionFactoryBuilder(ds); lsfb.setJtaTransactionManager(jtm); Object jtaPlatform = lsfb.getProperties().get(AvailableSettings.JTA_PLATFORM); assertNotNull(jtaPlatform); assertSame(tm, jtaPlatform.getClass().getMethod("retrieveTransactionManager").invoke(jtaPlatform)); assertSame(ut, jtaPlatform.getClass().getMethod("retrieveUserTransaction").invoke(jtaPlatform)); assertTrue(lsfb.getProperties().get(AvailableSettings.TRANSACTION_STRATEGY) instanceof CMTTransactionFactory); }
Example 3
Source File: JtaTransactionManagerSerializationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void serializable() throws Exception { UserTransaction ut1 = mock(UserTransaction.class); UserTransaction ut2 = mock(UserTransaction.class); TransactionManager tm = mock(TransactionManager.class); JtaTransactionManager jtam = new JtaTransactionManager(); jtam.setUserTransaction(ut1); jtam.setTransactionManager(tm); jtam.setRollbackOnCommitFailure(true); jtam.afterPropertiesSet(); SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder .emptyActivatedContextBuilder(); jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2); JtaTransactionManager serializedJtatm = (JtaTransactionManager) SerializationTestUtils .serializeAndDeserialize(jtam); // should do client-side lookup assertNotNull("Logger must survive serialization", serializedJtatm.logger); assertTrue("UserTransaction looked up on client", serializedJtatm .getUserTransaction() == ut2); assertNull("TransactionManager didn't survive", serializedJtatm .getTransactionManager()); assertEquals(true, serializedJtatm.isRollbackOnCommitFailure()); }
Example 4
Source File: JtaTransactionManagerSerializationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void serializable() throws Exception { UserTransaction ut1 = mock(UserTransaction.class); UserTransaction ut2 = mock(UserTransaction.class); TransactionManager tm = mock(TransactionManager.class); JtaTransactionManager jtam = new JtaTransactionManager(); jtam.setUserTransaction(ut1); jtam.setTransactionManager(tm); jtam.setRollbackOnCommitFailure(true); jtam.afterPropertiesSet(); SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder .emptyActivatedContextBuilder(); jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2); JtaTransactionManager serializedJtatm = (JtaTransactionManager) SerializationTestUtils .serializeAndDeserialize(jtam); // should do client-side lookup assertNotNull("Logger must survive serialization", serializedJtatm.logger); assertTrue("UserTransaction looked up on client", serializedJtatm .getUserTransaction() == ut2); assertNull("TransactionManager didn't survive", serializedJtatm .getTransactionManager()); assertEquals(true, serializedJtatm.isRollbackOnCommitFailure()); }
Example 5
Source File: SupportConfig.java From jeesupport with MIT License | 5 votes |
/** * spring jta 事务管理器,一般情况无需修改 * @param _utm * @param _uti * @return */ @Bean public JtaTransactionManager transactionManager(@Qualifier( "atomikosTM" ) UserTransactionManager _utm, @Qualifier( "atomikosUT" ) UserTransactionImp _uti ){ JtaTransactionManager jtm = new JtaTransactionManager(); jtm.setTransactionManager( _utm ); jtm.setUserTransaction( _uti ); jtm.setAllowCustomIsolationLevels( CommonConfig.getBoolean("jees.jdbs.trans.allowCustomIsolationLevels", false ) ); log.debug( "--Spring Bean[defaultTM]初始化." ); return jtm; }
Example 6
Source File: JtaTransactionManagerSerializationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void serializable() throws Exception { UserTransaction ut1 = mock(UserTransaction.class); UserTransaction ut2 = mock(UserTransaction.class); TransactionManager tm = mock(TransactionManager.class); JtaTransactionManager jtam = new JtaTransactionManager(); jtam.setUserTransaction(ut1); jtam.setTransactionManager(tm); jtam.setRollbackOnCommitFailure(true); jtam.afterPropertiesSet(); SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder .emptyActivatedContextBuilder(); jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2); JtaTransactionManager serializedJtatm = (JtaTransactionManager) SerializationTestUtils .serializeAndDeserialize(jtam); // should do client-side lookup assertNotNull("Logger must survive serialization", serializedJtatm.logger); assertTrue("UserTransaction looked up on client", serializedJtatm .getUserTransaction() == ut2); assertNull("TransactionManager didn't survive", serializedJtatm .getTransactionManager()); assertEquals(true, serializedJtatm.isRollbackOnCommitFailure()); }
Example 7
Source File: TransactionManagerProducer.java From wildfly-camel-examples with Apache License 2.0 | 5 votes |
@Produces @Named("jtaTransactionManager") public PlatformTransactionManager createTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setUserTransaction(userTransaction); jtaTransactionManager.afterPropertiesSet(); return jtaTransactionManager; }
Example 8
Source File: TransactionManagerProducer.java From wildfly-camel-examples with Apache License 2.0 | 5 votes |
@Produces @Named("transactionManager") public PlatformTransactionManager createTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setUserTransaction(userTransaction); jtaTransactionManager.setTransactionManager(transactionManager); jtaTransactionManager.afterPropertiesSet(); return jtaTransactionManager; }
Example 9
Source File: SpringCloudSecondaryConfiguration.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
public PlatformTransactionManager annotationDrivenTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setTransactionManager(this.applicationContext.getBean(TransactionManagerImpl.class)); jtaTransactionManager.setUserTransaction(this.applicationContext.getBean(UserCompensableImpl.class)); SpringContextRegistry springContextRegistry = SpringContextRegistry.getInstance(); springContextRegistry.setApplicationContext(this.applicationContext); springContextRegistry.setBeanFactory(this.beanFactory); springContextRegistry.setTransactionManager(jtaTransactionManager); return springContextRegistry.getTransactionManager(); }
Example 10
Source File: SpringCloudConfiguration.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
public PlatformTransactionManager annotationDrivenTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setTransactionManager(this.applicationContext.getBean(TransactionManagerImpl.class)); jtaTransactionManager.setUserTransaction(this.applicationContext.getBean(UserCompensableImpl.class)); SpringContextRegistry springContextRegistry = SpringContextRegistry.getInstance(); springContextRegistry.setApplicationContext(this.applicationContext); springContextRegistry.setBeanFactory(this.beanFactory); springContextRegistry.setTransactionManager(jtaTransactionManager); return springContextRegistry.getTransactionManager(); }
Example 11
Source File: DubboSecondaryConfiguration.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
public PlatformTransactionManager annotationDrivenTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setTransactionManager(this.applicationContext.getBean(TransactionManagerImpl.class)); jtaTransactionManager.setUserTransaction(this.applicationContext.getBean(UserCompensableImpl.class)); SpringContextRegistry springContextRegistry = SpringContextRegistry.getInstance(); springContextRegistry.setApplicationContext(this.applicationContext); springContextRegistry.setBeanFactory(this.beanFactory); springContextRegistry.setTransactionManager(jtaTransactionManager); return springContextRegistry.getTransactionManager(); }
Example 12
Source File: DubboSupportConfiguration.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
public PlatformTransactionManager annotationDrivenTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setTransactionManager(this.applicationContext.getBean(TransactionManagerImpl.class)); jtaTransactionManager.setUserTransaction(this.applicationContext.getBean(UserCompensableImpl.class)); SpringContextRegistry springContextRegistry = SpringContextRegistry.getInstance(); springContextRegistry.setApplicationContext(this.applicationContext); springContextRegistry.setBeanFactory(this.beanFactory); springContextRegistry.setTransactionManager(jtaTransactionManager); return springContextRegistry.getTransactionManager(); }
Example 13
Source File: SpringBootConfiguration.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
public PlatformTransactionManager annotationDrivenTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setTransactionManager(this.applicationContext.getBean(TransactionManagerImpl.class)); jtaTransactionManager.setUserTransaction(this.applicationContext.getBean(UserCompensableImpl.class)); SpringContextRegistry springContextRegistry = SpringContextRegistry.getInstance(); springContextRegistry.setApplicationContext(this.applicationContext); springContextRegistry.setBeanFactory(this.beanFactory); springContextRegistry.setTransactionManager(jtaTransactionManager); return springContextRegistry.getTransactionManager(); }
Example 14
Source File: SpringBootSecondaryConfiguration.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
public PlatformTransactionManager annotationDrivenTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setTransactionManager(this.applicationContext.getBean(TransactionManagerImpl.class)); jtaTransactionManager.setUserTransaction(this.applicationContext.getBean(UserCompensableImpl.class)); SpringContextRegistry springContextRegistry = SpringContextRegistry.getInstance(); springContextRegistry.setApplicationContext(this.applicationContext); springContextRegistry.setBeanFactory(this.beanFactory); springContextRegistry.setTransactionManager(jtaTransactionManager); return springContextRegistry.getTransactionManager(); }
Example 15
Source File: Config.java From tutorials with MIT License | 5 votes |
@Bean public JtaTransactionManager transactionManager() throws SystemException { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setTransactionManager(userTransactionManager()); jtaTransactionManager.setUserTransaction(userTransactionManager()); return jtaTransactionManager; }
Example 16
Source File: DubboSupportConfiguration.java From ByteJTA with GNU Lesser General Public License v3.0 | 4 votes |
public PlatformTransactionManager annotationDrivenTransactionManager() { JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); jtaTransactionManager.setTransactionManager(this.applicationContext.getBean(TransactionManager.class)); jtaTransactionManager.setUserTransaction(this.applicationContext.getBean(UserTransaction.class)); return jtaTransactionManager; }