当前位置: 首页>>代码示例>>Java>>正文


Java BitronixTransactionManager类代码示例

本文整理汇总了Java中bitronix.tm.BitronixTransactionManager的典型用法代码示例。如果您正苦于以下问题:Java BitronixTransactionManager类的具体用法?Java BitronixTransactionManager怎么用?Java BitronixTransactionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BitronixTransactionManager类属于bitronix.tm包,在下文中一共展示了BitronixTransactionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFind

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Test
public void testFind() throws ResourceException, NotSupportedException, SystemException {
	MicroserviceResourceFactory msrFactory = mock(MicroserviceResourceFactory.class);
	MicroserviceXAResource xa = new MicroserviceXAResource("a", mock(CommitRollbackCallback.class));
	when(msrFactory.build()).thenReturn(xa);
	MicroserviceResourceProducer.registerMicroserviceResourceFactory("a", msrFactory);
	MicroserviceResourceProducer producer = MicroserviceResourceProducer.getProducers().values().iterator().next();

       BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
       try{
       	tm.begin();

       	//TEST
       	producer.getTransactionAssistant(); //enlists resource into TX and means we can then go find it
       	
       	XAResource found = producer.findXAResourceHolder(xa).getXAResource();
       	assertEquals(xa, found);
       }finally{
       	tm.rollback();
       }
}
 
开发者ID:maxant,项目名称:genericconnector,代码行数:22,代码来源:MicroserviceResourceProducerTest.java

示例2: testXAWorksWithJsr107

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Test
public void testXAWorksWithJsr107() throws Exception {
  BitronixTransactionManager transactionManager = TransactionManagerServices.getTransactionManager();
  URI uri = getClass().getResource("/configs/simple-xa.xml").toURI();
  CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(uri, getClass().getClassLoader());

  Cache<String, String> xaCache = cacheManager.getCache("xaCache", String.class, String.class);

  transactionManager.begin();
  {
      xaCache.put("key", "one");
  }
  transactionManager.commit();

  cacheManager.close();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:17,代码来源:XA107Test.java

示例3: putIfAbsentAssertions

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
private void putIfAbsentAssertions(BitronixTransactionManager transactionManager, Cache<Long, String> txCache1) throws Exception {
  transactionManager.begin();
  {
    assertThat(txCache1.putIfAbsent(1L, "one"), is(nullValue()));
    assertThat(txCache1.putIfAbsent(1L, "un"), equalTo("one"));
  }
  transactionManager.commit();

  assertMapping(transactionManager, txCache1, 1L, "one");

  transactionManager.begin();
  {
    assertThat(txCache1.putIfAbsent(1L, "eins"), equalTo("one"));
    txCache1.remove(1L);
    assertThat(txCache1.putIfAbsent(1L, "een"), is(nullValue()));
  }
  transactionManager.commit();

  assertMapping(transactionManager, txCache1, 1L, "een");
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:21,代码来源:XACacheTest.java

示例4: replace2ArgsAssertions

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
private void replace2ArgsAssertions(BitronixTransactionManager transactionManager, Cache<Long, String> txCache1) throws Exception {
  transactionManager.begin();
  {
    assertThat(txCache1.replace(1L, "one"), is(nullValue()));
    txCache1.put(1L, "un");
    assertThat(txCache1.replace(1L, "eins"), equalTo("un"));
  }
  transactionManager.commit();

  assertMapping(transactionManager, txCache1, 1L, "eins");

  transactionManager.begin();
  {
    assertThat(txCache1.replace(1L, "een"), equalTo("eins"));
    txCache1.put(1L, "un");
    assertThat(txCache1.replace(1L, "een"), equalTo("un"));
    txCache1.remove(1L);
    assertThat(txCache1.replace(1L, "one"), is(nullValue()));
    assertThat(txCache1.get(1L), is(nullValue()));
  }
  transactionManager.commit();

  assertMapping(transactionManager, txCache1, 1L, null);
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:XACacheTest.java

示例5: replace3ArgsAssertions

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
private void replace3ArgsAssertions(BitronixTransactionManager transactionManager, Cache<Long, String> txCache1) throws Exception {
  transactionManager.begin();
  {
    assertThat(txCache1.replace(1L, "one", "un"), is(false));
    txCache1.put(1L, "un");
    assertThat(txCache1.replace(1L, "uno", "eins"), is(false));
    assertThat(txCache1.replace(1L, "un", "eins"), is(true));
    assertThat(txCache1.get(1L), equalTo("eins"));
  }
  transactionManager.commit();

  assertMapping(transactionManager, txCache1, 1L, "eins");

  transactionManager.begin();
  {
    assertThat(txCache1.replace(1L, "one", "un"), is(false));
    assertThat(txCache1.replace(1L, "eins", "un"), is(true));
    assertThat(txCache1.replace(1L, "uno", "een"), is(false));
    assertThat(txCache1.get(1L), equalTo("un"));
  }
  transactionManager.commit();

  assertMapping(transactionManager, txCache1, 1L, "un");
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:XACacheTest.java

示例6: testXAWithStatefulSerializer

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Test
public void testXAWithStatefulSerializer() throws Exception {
  BitronixTransactionManager manager = TransactionManagerServices.getTransactionManager();
  try (CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
        .using(new LookupTransactionManagerProviderConfiguration(
          BitronixTransactionManagerLookup.class))
        .withCache("xaCache",
          CacheConfigurationBuilder
            .newCacheConfigurationBuilder(Long.class, Person.class,
              ResourcePoolsBuilder.heap(5))
            .withExpiry(ExpiryPolicyBuilder.noExpiration()).add(new XAStoreConfiguration("xaCache"))
            .build())
        .build(true)) {

    Cache<Long, Person> cache = cacheManager.getCache("xaCache", Long.class, Person.class);
    manager.begin();
    cache.put(1L, new Person("James", 42));
    manager.commit();

    manager.begin();
    assertNotNull(cache.get(1L));
    manager.commit();
  } finally {
    manager.shutdown();
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:27,代码来源:StatefulSerializerTest.java

示例7: testClusteredCacheWithXA

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Test
public void testClusteredCacheWithXA() throws Exception {
  TransactionManagerServices.getConfiguration().setJournal("null");

  BitronixTransactionManager transactionManager =
      TransactionManagerServices.getTransactionManager();

  PersistentCacheManager persistentCacheManager = null;
  try {
    CacheManagerBuilder.newCacheManagerBuilder()
        .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class))
        .with(ClusteringServiceConfigurationBuilder.cluster(URI.create("terracotta://localhost/my-application")).autoCreate())
        .withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
            ResourcePoolsBuilder.newResourcePoolsBuilder()
                .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 8, MemoryUnit.MB))
            )
                .add(new XAStoreConfiguration("xaCache"))
                .build()
        )
        .build(true);
  } catch (StateTransitionException e) {
    assertThat(e.getCause().getCause().getMessage(), is("Unsupported resource type : interface org.ehcache.clustered.client.config.DedicatedClusteredResourcePool"));
  }

  transactionManager.shutdown();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:27,代码来源:UnSupportedCombinationsWIthClusteredCacheTest.java

示例8: stop

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Override
public void stop(BundleContext context) throws Exception {
	BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
       tm.shutdown();

       tmRegistration.unregister();
       utRegistration.unregister();

       for (ServiceRegistration reg : dsRegistrations.values()) {
           reg.unregister();
       }
       dsRegistrations.clear();

       Configuration conf = TransactionManagerServices.getConfiguration();
       log.info(String.format("Stopped JTA for server ID '%s'.", conf.getServerId()));
}
 
开发者ID:bitronix,项目名称:btm,代码行数:17,代码来源:Activator.java

示例9: testPrepares

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Test
public void testPrepares() throws Exception {
    BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
    tm.setTransactionTimeout(60);
    tm.begin();

    Connection connection = poolingDataSource2.getConnection();

    for (int i = 0; i < 1000; i++) {
        PreparedStatement prepareStatement = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");
        assertFalse(prepareStatement.isClosed());
        prepareStatement.close();
        assertTrue(prepareStatement.isClosed());
    }

    connection.close();

    tm.commit();
    tm.shutdown();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:21,代码来源:JdbcProxyTest.java

示例10: testCachedPrepared

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Test
public void testCachedPrepared() throws Exception {
    BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
    tm.setTransactionTimeout(60);
    tm.begin();

    Connection connection = poolingDataSource1.getConnection();

    PreparedStatement prepareStatement1 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");
    PreparedStatement prepareStatement2 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");

    Assert.assertSame(prepareStatement1.unwrap(PreparedStatement.class), prepareStatement2.unwrap(PreparedStatement.class));

    prepareStatement2.close();

    prepareStatement2 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");
    Assert.assertSame(prepareStatement1.unwrap(PreparedStatement.class), prepareStatement2.unwrap(PreparedStatement.class));

    prepareStatement1.close();
    prepareStatement2.close();

    connection.close();
    tm.shutdown();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:25,代码来源:JdbcProxyTest.java

示例11: testCachedStatementsCanBeReused

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Test
public void testCachedStatementsCanBeReused() throws Exception {
    BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
    tm.setTransactionTimeout(60);
    tm.begin();
    try {
        Connection connection = poolingDataSource1.getConnection();
        try {
            PreparedStatement prepareStatement1 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");
            assertFalse(prepareStatement1.isClosed());

            prepareStatement1.close();
            assertTrue(prepareStatement1.isClosed());

            PreparedStatement prepareStatement2 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");
            assertFalse(prepareStatement2.isClosed());
        } finally {
            connection.close();
        }
    } finally {
        tm.shutdown();
    }
}
 
开发者ID:bitronix,项目名称:btm,代码行数:24,代码来源:JdbcProxyTest.java

示例12: testUnCachedPrepared

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Test
public void testUnCachedPrepared() throws Exception {
    BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
    tm.setTransactionTimeout(60);
    tm.begin();

    Connection connection = poolingDataSource2.getConnection();

    PreparedStatement prepareStatement1 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");
    PreparedStatement prepareStatement2 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");

    Assert.assertNotSame(prepareStatement1.unwrap(PreparedStatement.class), prepareStatement2.unwrap(PreparedStatement.class));

    prepareStatement2.close();

    prepareStatement2 = connection.prepareStatement("SELECT 1 FROM nothing WHERE a=? AND b=? AND c=? AND d=?");
    Assert.assertNotSame(prepareStatement1.unwrap(PreparedStatement.class), prepareStatement2.unwrap(PreparedStatement.class));

    prepareStatement1.close();
    prepareStatement2.close();

    connection.close();
    tm.shutdown();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:25,代码来源:JdbcProxyTest.java

示例13: testUnSharedConnection

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
public void testUnSharedConnection() throws Exception {
    if (log.isDebugEnabled()) { log.debug("*** Starting testUnSharedConnection: getting TM"); }
    BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
    tm.setTransactionTimeout(120);

    if (log.isDebugEnabled()) { log.debug("*** before begin"); }
    tm.begin();
    if (log.isDebugEnabled()) { log.debug("*** after begin"); }

    if (log.isDebugEnabled()) { log.debug("*** getting connection from DS2"); }
    Connection connection1 = poolingDataSource2.getConnection();
    // createStatement causes enlistment
    connection1.createStatement();

    if (log.isDebugEnabled()) { log.debug("*** getting second connection from DS2"); }
    Connection connection2 = poolingDataSource2.getConnection();

    PooledConnectionProxy handle1 = (PooledConnectionProxy) connection1;
    PooledConnectionProxy handle2 = (PooledConnectionProxy) connection2;
    assertNotSame(handle1.getProxiedDelegate(), handle2.getProxiedDelegate());

    connection1.close();
    connection2.close();

    tm.commit();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:27,代码来源:JdbcSharedConnectionTest.java

示例14: testSharedConnectionInGlobal

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
public void testSharedConnectionInGlobal() throws Exception {
    if (log.isDebugEnabled()) { log.debug("*** testSharedConnectionInGlobal: Starting getting TM"); }
    BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
    tm.setTransactionTimeout(120);

    if (log.isDebugEnabled()) { log.debug("*** before begin"); }
    tm.begin();
    if (log.isDebugEnabled()) { log.debug("*** after begin"); }

    if (log.isDebugEnabled()) { log.debug("*** getting connection from DS1"); }
    Connection connection1 = poolingDataSource1.getConnection();

    if (log.isDebugEnabled()) { log.debug("*** getting second connection from DS1"); }
    Connection connection2 = poolingDataSource1.getConnection();

    PooledConnectionProxy handle1 = (PooledConnectionProxy) connection1;
    PooledConnectionProxy handle2 = (PooledConnectionProxy) connection2;
    assertSame(handle1.getProxiedDelegate(), handle2.getProxiedDelegate());

    connection1.close();
    connection2.close();

    tm.commit();
}
 
开发者ID:bitronix,项目名称:btm,代码行数:25,代码来源:JdbcSharedConnectionTest.java

示例15: bitronixTransactionManager

import bitronix.tm.BitronixTransactionManager; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(TransactionManager.class)
public BitronixTransactionManager bitronixTransactionManager(
		bitronix.tm.Configuration configuration) {
	// Inject configuration to force ordering
	return TransactionManagerServices.getTransactionManager();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:BitronixJtaConfiguration.java


注:本文中的bitronix.tm.BitronixTransactionManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。