gpt4 book ai didi

org.ehcache.transactions.xa.configuration.XAStoreConfiguration类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 23:02:40 26 4
gpt4 key购买 nike

本文整理了Java中org.ehcache.transactions.xa.configuration.XAStoreConfiguration类的一些代码示例,展示了XAStoreConfiguration类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XAStoreConfiguration类的具体详情如下:
包路径:org.ehcache.transactions.xa.configuration.XAStoreConfiguration
类名称:XAStoreConfiguration

XAStoreConfiguration介绍

暂无

代码示例

代码示例来源:origin: ehcache/ehcache3

@Override
public ServiceConfiguration<XAStore.Provider> parseServiceConfiguration(Element fragment, ClassLoader classLoader) {
 String localName = fragment.getLocalName();
 if ("xa-store".equals(localName)) {
  String uniqueXAResourceId = fragment.getAttribute("unique-XAResource-id");
  return new XAStoreConfiguration(uniqueXAResourceId);
 } else {
  throw new XmlConfigurationException(String.format("XML configuration element <%s> in <%s> is not supported",
    fragment.getTagName(), (fragment.getParentNode() == null ? "null" : fragment.getParentNode().getLocalName())));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Override
protected Element createRootElement(Document doc, XAStoreConfiguration storeConfiguration) {
 Element rootElement = doc.createElementNS(NAMESPACE.toString(), TRANSACTION_NAMESPACE_PREFIX  + STORE_ELEMENT_NAME);
 rootElement.setAttribute(UNIQUE_RESOURCE_NAME, storeConfiguration.getUniqueXAResourceId());
 return rootElement;
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testTranslateServiceConfiguration() {
 TxCacheServiceConfigurationParser configTranslator = new TxCacheServiceConfigurationParser();
 XAStoreConfiguration storeConfiguration = new XAStoreConfiguration("my-unique-resource");
 Node retElement = configTranslator.unparseServiceConfiguration(storeConfiguration);
 String inputString = "<tx:xa-store unique-XAResource-id = \"my-unique-resource\" " +
            "xmlns:tx = \"http://www.ehcache.org/v3/tx\"/>";
 assertElement(inputString, retElement);
}

代码示例来源:origin: ehcache/ehcache3

@Test
 public void testTemplateConfigOverride() throws Exception {
  final URL myUrl = this.getClass().getResource("/configs/template-xa.xml");
  Configuration xmlConfig = new XmlConfiguration(myUrl);
  CacheConfiguration<?, ?> cacheConfiguration = xmlConfig.getCacheConfigurations().get("xaCache1");
  XAStoreConfiguration xaStoreConfiguration = ServiceUtils.findSingletonAmongst(XAStoreConfiguration.class, cacheConfiguration
    .getServiceConfigurations());

  assertThat(xaStoreConfiguration.getUniqueXAResourceId(), is("xaCache1"));
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testRank() throws Exception {
 XAStore.Provider provider = new XAStore.Provider();
 XAStoreConfiguration configuration = new XAStoreConfiguration("testXAResourceId");
 ServiceLocator serviceLocator = dependencySet()
  .with(provider)
  .with(Store.Provider.class)
  .with(mock(DiskResourceService.class))
  .with(mock(TransactionManagerProvider.class)).build();
 serviceLocator.startAllServices();
 Set<ServiceConfiguration<?>> xaStoreConfigs = Collections.singleton(configuration);
 assertThat(provider.wrapperStoreRank(xaStoreConfigs), is(1));
 Set<ServiceConfiguration<?>> emptyConfigs = emptySet();
 assertThat(provider.wrapperStoreRank(emptyConfigs), is(0));
}

代码示例来源:origin: ehcache/ehcache3

storeConfig.getResourcePools().getResourceTypeSet(), serviceConfigList);
String uniqueXAResourceId = xaServiceConfiguration.getUniqueXAResourceId();
List<ServiceConfiguration<?>> underlyingServiceConfigs = new ArrayList<>(serviceConfigList.size() + 5); // pad a bit because we add stuff
underlyingServiceConfigs.addAll(serviceConfigList);

代码示例来源:origin: ehcache/ehcache3

.withCache("txCache1", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache1")).build())
.using(new DefaultTimeSourceService(new TimeSourceConfiguration(testTimeSource)))
.using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class))

代码示例来源:origin: org.ehcache/ehcache-transactions

@Override
protected Element createRootElement(Document doc, XAStoreConfiguration storeConfiguration) {
 Element rootElement = doc.createElementNS(NAMESPACE.toString(), TRANSACTION_NAMESPACE_PREFIX  + STORE_ELEMENT_NAME);
 rootElement.setAttribute(UNIQUE_RESOURCE_NAME, storeConfiguration.getUniqueXAResourceId());
 return rootElement;
}

代码示例来源:origin: ehcache/ehcache3

.withCache("txCache1", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache1")).build())
.withCache("txCache2", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache2")).build())
.using(new DefaultTimeSourceService(new TimeSourceConfiguration(testTimeSource)))
.using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class))

代码示例来源:origin: org.ehcache/ehcache-transactions

selectProvider(configuredTypes, serviceConfigList, xaServiceConfiguration);
String uniqueXAResourceId = xaServiceConfiguration.getUniqueXAResourceId();
List<ServiceConfiguration<?>> underlyingServiceConfigs = new ArrayList<>(serviceConfigList.size() + 5); // pad a bit because we add stuff
underlyingServiceConfigs.addAll(serviceConfigList);

代码示例来源:origin: ehcache/ehcache3

@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();
}

代码示例来源:origin: ehcache/ehcache3

.withCache("txCache1", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache1")).build())
.withCache("txCache2", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache2")).build())
.using(new DefaultTimeSourceService(new TimeSourceConfiguration(testTimeSource)))
.using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class))

代码示例来源:origin: ehcache/ehcache3

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))
   .add(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();
}

代码示例来源:origin: ehcache/ehcache3

@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>
       .add(new XAStoreConfiguration("xaCache")) // <5>
       .add(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[]
}

代码示例来源:origin: ehcache/ehcache3

.withCache("txCache1", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache1")).build())
.withCache("txCache2", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache2")).build())
.using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class))
.build(true);

代码示例来源:origin: ehcache/ehcache3

@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>
     .add(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[]
}

代码示例来源:origin: ehcache/ehcache3

.withCache("txCache1", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache1")).build())
.withCache("txCache2", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache2")).build())
.withCache("nonTxCache", cacheConfigurationBuilder.build())
.build(true);

代码示例来源:origin: ehcache/ehcache3

@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)
       )
       .add(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[]
}

代码示例来源:origin: ehcache/ehcache3

@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>
     .add(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[]
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testAtomicsWithoutLoaderWriter() throws Exception {
 CacheConfigurationBuilder<Long, String> cacheConfigurationBuilder = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
   newResourcePoolsBuilder()
         .heap(10, EntryUnit.ENTRIES)
         .offheap(10, MemoryUnit.MB)
       )
   .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(1)));
 cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
   .withCache("txCache1", cacheConfigurationBuilder.add(new XAStoreConfiguration("txCache1")).build())
   .using(new DefaultTimeSourceService(new TimeSourceConfiguration(testTimeSource)))
   .using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class))
   .build(true);
 Cache<Long, String> txCache1 = cacheManager.getCache("txCache1", Long.class, String.class);
 putIfAbsentAssertions(transactionManager, txCache1);
 txCache1.clear();
 remove2ArgsAssertions(transactionManager, txCache1);
 txCache1.clear();
 replace2ArgsAssertions(transactionManager, txCache1);
 txCache1.clear();
 replace3ArgsAssertions(transactionManager, txCache1);
 txCache1.clear();
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com