Java Code Examples for bitronix.tm.BitronixTransactionManager#shutdown()
The following examples show how to use
bitronix.tm.BitronixTransactionManager#shutdown() .
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: TransactionalOsgiTest.java From ehcache3 with Apache License 2.0 | 6 votes |
public static void testProgrammaticConfiguration() throws Exception { BitronixTransactionManager transactionManager = getTransactionManager(); try (CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .withClassLoader(TestMethods.class.getClassLoader()) .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class)) .withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(10)) .withService(new XAStoreConfiguration("xaCache")).build()).build(true)) { Cache<Long, String> xaCache = cacheManager.getCache("xaCache", Long.class, String.class); transactionManager.begin(); try { xaCache.put(1L, "one"); } catch (Throwable t) { transactionManager.rollback(); } transactionManager.commit(); } transactionManager.shutdown(); }
Example 2
Source File: TransactionalOsgiTest.java From ehcache3 with Apache License 2.0 | 6 votes |
public static void testXmlConfiguration() throws Exception { BitronixTransactionManager transactionManager = getTransactionManager(); try (CacheManager cacheManager = newCacheManager( new XmlConfiguration(TestMethods.class.getResource("ehcache-xa-osgi.xml"), TestMethods.class.getClassLoader()) )) { cacheManager.init(); Cache<Long, String> xaCache = cacheManager.getCache("xaCache", Long.class, String.class); transactionManager.begin(); try { xaCache.put(1L, "one"); } catch (Throwable t) { transactionManager.rollback(); } transactionManager.commit(); } transactionManager.shutdown(); }
Example 3
Source File: StatefulSerializerTest.java From ehcache3 with Apache License 2.0 | 6 votes |
@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()).withService(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(); } }
Example 4
Source File: UnSupportedCombinationsWithClusteredCacheTest.java From ehcache3 with Apache License 2.0 | 6 votes |
@Test public void testClusteredCacheWithXA() throws Exception { TransactionManagerServices.getConfiguration().setJournal("null"); BitronixTransactionManager transactionManager = TransactionManagerServices.getTransactionManager(); try { CacheManagerBuilder.newCacheManagerBuilder() .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class)) .with(ClusteringServiceConfigurationBuilder.cluster(URI.create("terracotta://localhost/my-application")).autoCreate(c -> c)) .withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, ResourcePoolsBuilder.newResourcePoolsBuilder() .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 8, MemoryUnit.MB)) ) .withService(new XAStoreConfiguration("xaCache")) .build() ) .build(true).close(); fail("Expected StateTransitionException"); } catch (StateTransitionException e) { assertThat(e.getCause().getCause().getMessage(), is("Unsupported resource type : interface org.ehcache.clustered.client.config.DedicatedClusteredResourcePool")); } transactionManager.shutdown(); }
Example 5
Source File: XAGettingStarted.java From ehcache3 with Apache License 2.0 | 5 votes |
@Test public void testSimpleXACache() throws Exception { // tag::testSimpleXACache[] BitronixTransactionManager transactionManager = TransactionManagerServices.getTransactionManager(); // <1> CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class)) // <2> .withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, // <3> ResourcePoolsBuilder.heap(10)) // <4> .withService(new XAStoreConfiguration("xaCache")) // <5> .build() ) .build(true); Cache<Long, String> xaCache = cacheManager.getCache("xaCache", Long.class, String.class); transactionManager.begin(); // <6> { xaCache.put(1L, "one"); // <7> } transactionManager.commit(); // <8> cacheManager.close(); transactionManager.shutdown(); // end::testSimpleXACache[] }
Example 6
Source File: XAGettingStarted.java From ehcache3 with Apache License 2.0 | 5 votes |
@Test public void testNonTransactionalAccess() throws Exception { // tag::testNonTransactionalAccess[] BitronixTransactionManager transactionManager = TransactionManagerServices.getTransactionManager(); // <1> CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class)) // <2> .withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, // <3> ResourcePoolsBuilder.heap(10)) // <4> .withService(new XAStoreConfiguration("xaCache")) // <5> .build() ) .build(true); Cache<Long, String> xaCache = cacheManager.getCache("xaCache", Long.class, String.class); try { xaCache.get(1L); // <6> fail("expected XACacheException"); } catch (XACacheException e) { // expected } cacheManager.close(); transactionManager.shutdown(); // end::testNonTransactionalAccess[] }
Example 7
Source File: XAGettingStarted.java From ehcache3 with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("unchecked") public void testXACacheWithWriteThrough() throws Exception { // tag::testXACacheWithWriteThrough[] BitronixTransactionManager transactionManager = TransactionManagerServices.getTransactionManager(); // <1> Class<CacheLoaderWriter<?, ?>> klazz = (Class<CacheLoaderWriter<?, ?>>) (Class) (SampleLoaderWriter.class); CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class)) // <2> .withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, // <3> ResourcePoolsBuilder.heap(10)) // <4> .withService(new XAStoreConfiguration("xaCache")) // <5> .withService(new DefaultCacheLoaderWriterConfiguration(klazz, singletonMap(1L, "eins"))) // <6> .build() ) .build(true); Cache<Long, String> xaCache = cacheManager.getCache("xaCache", Long.class, String.class); transactionManager.begin(); // <7> { assertThat(xaCache.get(1L), equalTo("eins")); // <8> xaCache.put(1L, "one"); // <9> } transactionManager.commit(); // <10> cacheManager.close(); transactionManager.shutdown(); // end::testXACacheWithWriteThrough[] }
Example 8
Source File: XAGettingStarted.java From ehcache3 with Apache License 2.0 | 5 votes |
@Test public void testXACacheWithThreeTiers() throws Exception { // tag::testXACacheWithThreeTiers[] BitronixTransactionManager transactionManager = TransactionManagerServices.getTransactionManager(); // <1> PersistentCacheManager persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder() .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class)) // <2> .with(CacheManagerBuilder.persistence(new File(getStoragePath(), "testXACacheWithThreeTiers"))) // <3> .withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, // <4> ResourcePoolsBuilder.newResourcePoolsBuilder() // <5> .heap(10, EntryUnit.ENTRIES) .offheap(10, MemoryUnit.MB) .disk(20, MemoryUnit.MB, true) ) .withService(new XAStoreConfiguration("xaCache")) // <6> .build() ) .build(true); Cache<Long, String> xaCache = persistentCacheManager.getCache("xaCache", Long.class, String.class); transactionManager.begin(); // <7> { xaCache.put(1L, "one"); // <8> } transactionManager.commit(); // <9> persistentCacheManager.close(); transactionManager.shutdown(); // end::testXACacheWithThreeTiers[] }
Example 9
Source File: XAGettingStarted.java From ehcache3 with Apache License 2.0 | 5 votes |
@Test public void testXACacheWithXMLConfig() throws Exception { // tag::testXACacheWithXMLConfig[] BitronixTransactionManager transactionManager = TransactionManagerServices.getTransactionManager(); // <1> URL myUrl = this.getClass().getResource("/docs/configs/xa-getting-started.xml"); // <2> Configuration xmlConfig = new XmlConfiguration(myUrl); // <3> CacheManager myCacheManager = CacheManagerBuilder.newCacheManager(xmlConfig); // <4> myCacheManager.init(); myCacheManager.close(); transactionManager.shutdown(); // end::testXACacheWithXMLConfig[] }
Example 10
Source File: XmlConfigTest.java From ehcache3 with Apache License 2.0 | 5 votes |
@Test public void testSimpleConfig() throws Exception { TransactionManagerServices.getConfiguration().setJournal("null").setServerId("XmlConfigTest"); BitronixTransactionManager transactionManager = TransactionManagerServices.getTransactionManager(); final URL myUrl = this.getClass().getResource("/configs/simple-xa.xml"); Configuration xmlConfig = new XmlConfiguration(myUrl); CacheManager myCacheManager = CacheManagerBuilder.newCacheManager(xmlConfig); myCacheManager.init(); myCacheManager.close(); transactionManager.shutdown(); }