• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java XmlConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
public static void main(String[] args) {
  LOGGER.info("Creating cache manager via XML resource");
  Configuration xmlConfig = new XmlConfiguration(BasicXML.class.getResource("/ehcache.xml"));
  try (CacheManager cacheManager = newCacheManager(xmlConfig)) {
    cacheManager.init();

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

    LOGGER.info("Putting to cache");
    basicCache.put(1L, "da one!");
    String value = basicCache.get(1L);
    LOGGER.info("Retrieved '{}'", value);

    LOGGER.info("Closing cache manager");
  }

  LOGGER.info("Exiting");
}
 
开发者ID:ehcache,项目名称:ehcache3-samples,代码行数:19,代码来源:BasicXML.java


示例2: main

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
public static void main(String[] args) {
  LOGGER.info("Creating clustered cache manager from XML");
  final URL myUrl = ClusteredXML.class.getResource("/ehcache.xml");
  Configuration xmlConfig = new XmlConfiguration(myUrl);
  try (CacheManager cacheManager = newCacheManager(xmlConfig)) {
    cacheManager.init();
    
    Cache<Long, String> basicCache = cacheManager.getCache("basicCache", Long.class, String.class);
    
    LOGGER.info("Getting from cache");
    String value = basicCache.get(1L);
    LOGGER.info("Retrieved '{}'", value);

    LOGGER.info("Closing cache manager");
  }

  LOGGER.info("Exiting");
}
 
开发者ID:ehcache,项目名称:ehcache3-samples,代码行数:19,代码来源:ClusteredXML.java


示例3: createCacheManager

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
CacheManager createCacheManager() throws IOException {
    CacheManager manager;

    if (cacheManager != null) {
        manager = cacheManager;
    } else if (configUri != null) {
        manager = CacheManagerBuilder.newCacheManager(new XmlConfiguration(getConfigUriAsUrl()));
    } else {
        CacheManagerBuilder builder = CacheManagerBuilder.newCacheManagerBuilder();
        if (configuration != null) {
            builder.withCache(cacheName, configuration);
        }

        manager = builder.build();
    }

    return manager;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:EhcacheConfiguration.java


示例4: jsr107DefaultEh107IdentityCopierForImmutableTypesWithCMLevelDefaults

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void jsr107DefaultEh107IdentityCopierForImmutableTypesWithCMLevelDefaults() {
  XmlConfiguration xmlConfiguration = new XmlConfiguration(getClass().getResource("/ehcache-107-immutable-types-cm-level-copiers.xml"));
  final DefaultJsr107Service jsr107Service = new DefaultJsr107Service(ServiceUtils.findSingletonAmongst(Jsr107Configuration.class, xmlConfiguration.getServiceCreationConfigurations().toArray()));
  merger = new ConfigurationMerger(xmlConfiguration, jsr107Service, mock(Eh107CacheLoaderWriterProvider.class));

  MutableConfiguration<Long, String> stringCacheConfiguration  = new MutableConfiguration<>();
  stringCacheConfiguration.setTypes(Long.class, String.class);
  ConfigurationMerger.ConfigHolder<Long, String> configHolder1 = merger.mergeConfigurations("stringCache", stringCacheConfiguration);

  assertThat(configHolder1.cacheConfiguration.getServiceConfigurations().isEmpty(), is(true));

  for (ServiceCreationConfiguration<?> serviceCreationConfiguration : xmlConfiguration.getServiceCreationConfigurations()) {
    if (serviceCreationConfiguration instanceof DefaultCopyProviderConfiguration) {
      DefaultCopyProviderConfiguration copierConfig = (DefaultCopyProviderConfiguration)serviceCreationConfiguration;
      assertThat(copierConfig.getDefaults().size(), is(6));
      assertThat(copierConfig.getDefaults().get(Long.class).getClazz().isAssignableFrom(IdentityCopier.class), is(true));
      assertThat(copierConfig.getDefaults().get(String.class).getClazz().isAssignableFrom(Eh107IdentityCopier.class), is(true));
      assertThat(copierConfig.getDefaults().get(Float.class).getClazz().isAssignableFrom(Eh107IdentityCopier.class), is(true));
      assertThat(copierConfig.getDefaults().get(Double.class).getClazz().isAssignableFrom(Eh107IdentityCopier.class), is(true));
      assertThat(copierConfig.getDefaults().get(Character.class).getClazz().isAssignableFrom(Eh107IdentityCopier.class), is(true));
      assertThat(copierConfig.getDefaults().get(Integer.class).getClazz().isAssignableFrom(Eh107IdentityCopier.class), is(true));
    }
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:26,代码来源:ConfigurationMergerTest.java


示例5: doPreSetup

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Override
protected void doPreSetup() throws Exception {
    final URL url = this.getClass().getResource(EHCACHE_CONFIG);
    final Configuration xmlConfig = new XmlConfiguration(url);

    cacheManager = CacheManagerBuilder.newCacheManager(xmlConfig);
    cacheManager.init();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:EhcacheTestSupport.java


示例6: test_config_loaded

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void test_config_loaded() throws Exception {
  CacheManager myCacheManager = CacheManagerBuilder.newCacheManager(new XmlConfiguration(getClass().getClassLoader().getResource(xml)));
  myCacheManager.init();
  try {
    DefaultManagementRegistryConfiguration registryConfiguration = null;

    for (ServiceCreationConfiguration<?> configuration : myCacheManager.getRuntimeConfiguration().getServiceCreationConfigurations()) {
      if (configuration instanceof DefaultManagementRegistryConfiguration) {
        registryConfiguration = (DefaultManagementRegistryConfiguration) configuration;
        break;
      }
    }

    assertThat(registryConfiguration, is(not(nullValue())));

    // 1st test: CM alia not set, so generated
    if (xml.endsWith("-1.xml")) {
      expectedConfiguration.setCacheManagerAlias(registryConfiguration.getContext().get("cacheManagerName"));
    }

    assertThat(registryConfiguration, equalTo(expectedConfiguration));

  } finally {
    myCacheManager.close();
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:28,代码来源:XmlConfigTest.java


示例7: xmlConfigSample

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void xmlConfigSample() throws Exception {
  // tag::xmlConfig[]
  final URL myUrl = getClass().getResource("/configs/docs/getting-started.xml"); // <1>
  XmlConfiguration xmlConfig = new XmlConfiguration(myUrl); // <2>
  CacheManager myCacheManager = CacheManagerBuilder.newCacheManager(xmlConfig); // <3>
  myCacheManager.init();  // <4>
  // end::xmlConfig[]
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:10,代码来源:GettingStarted.java


示例8: xmlTemplateSample

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void xmlTemplateSample() throws Exception {
  // tag::xmlTemplate[]
  XmlConfiguration xmlConfiguration = new XmlConfiguration(getClass().getResource("/configs/docs/template-sample.xml"));
  CacheConfigurationBuilder<Long, String> configurationBuilder = xmlConfiguration.newCacheConfigurationBuilderFromTemplate("example", Long.class, String.class); // <1>
  configurationBuilder = configurationBuilder.withResourcePools(ResourcePoolsBuilder.heap(1000)); // <2>
  // end::xmlTemplate[]
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:9,代码来源:GettingStarted.java


示例9: ConfigurationMerger

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
ConfigurationMerger(org.ehcache.config.Configuration ehConfig, Jsr107Service jsr107Service, Eh107CacheLoaderWriterProvider cacheLoaderWriterFactory) {
  if (ehConfig instanceof XmlConfiguration) {
    xmlConfiguration = (XmlConfiguration) ehConfig;
  } else {
    xmlConfiguration = null;
  }
  this.jsr107Service = jsr107Service;
  this.cacheLoaderWriterFactory = cacheLoaderWriterFactory;
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:10,代码来源:ConfigurationMerger.java


示例10: testConfigParse

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void testConfigParse() throws ClassNotFoundException, SAXException, InstantiationException, IllegalAccessException, IOException {
  final XmlConfiguration configuration = new XmlConfiguration(this.getClass().getResource("/ehcache-107.xml"));
  final DefaultJsr107Service jsr107Service = new DefaultJsr107Service(ServiceUtils.findSingletonAmongst(Jsr107Configuration.class, configuration.getServiceCreationConfigurations().toArray()));

  final CacheManager cacheManager = new EhcacheManager(configuration, Collections.<Service>singletonList(jsr107Service));
  cacheManager.init();

  assertThat(jsr107Service.getTemplateNameForCache("foos"), equalTo("stringCache"));
  assertThat(jsr107Service.getTemplateNameForCache("bars"), equalTo("tinyCache"));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:12,代码来源:ParsesConfigurationExtensionTest.java


示例11: setUp

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Before
public void setUp() {
  xmlConfiguration = mock(XmlConfiguration.class);
  jsr107Service = mock(Jsr107Service.class);
  cacheLoaderWriterFactory = mock(Eh107CacheLoaderWriterProvider.class);
  merger = new ConfigurationMerger(xmlConfiguration, jsr107Service, cacheLoaderWriterFactory);
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:8,代码来源:ConfigurationMergerTest.java


示例12: jsr107DefaultEh107IdentityCopierForImmutableTypes

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void jsr107DefaultEh107IdentityCopierForImmutableTypes() {
  XmlConfiguration xmlConfiguration = new XmlConfiguration(getClass().getResource("/ehcache-107-copiers-immutable-types.xml"));
  final DefaultJsr107Service jsr107Service = new DefaultJsr107Service(ServiceUtils.findSingletonAmongst(Jsr107Configuration.class, xmlConfiguration.getServiceCreationConfigurations().toArray()));
  merger = new ConfigurationMerger(xmlConfiguration, jsr107Service, mock(Eh107CacheLoaderWriterProvider.class));

  MutableConfiguration<Long, String> stringCacheConfiguration  = new MutableConfiguration<>();
  stringCacheConfiguration.setTypes(Long.class, String.class);
  ConfigurationMerger.ConfigHolder<Long, String> configHolder1 = merger.mergeConfigurations("stringCache", stringCacheConfiguration);

  assertDefaultCopier(configHolder1.cacheConfiguration.getServiceConfigurations());

  MutableConfiguration<Long, Double> doubleCacheConfiguration  = new MutableConfiguration<>();
  doubleCacheConfiguration.setTypes(Long.class, Double.class);
  ConfigurationMerger.ConfigHolder<Long, Double> configHolder2 = merger.mergeConfigurations("doubleCache", doubleCacheConfiguration);

  assertDefaultCopier(configHolder2.cacheConfiguration.getServiceConfigurations());

  MutableConfiguration<Long, Character> charCacheConfiguration  = new MutableConfiguration<>();
  charCacheConfiguration.setTypes(Long.class, Character.class);
  ConfigurationMerger.ConfigHolder<Long, Character> configHolder3 = merger.mergeConfigurations("charCache", charCacheConfiguration);

  assertDefaultCopier(configHolder3.cacheConfiguration.getServiceConfigurations());

  MutableConfiguration<Long, Float> floatCacheConfiguration  = new MutableConfiguration<>();
  floatCacheConfiguration.setTypes(Long.class, Float.class);
  ConfigurationMerger.ConfigHolder<Long, Float> configHolder4 = merger.mergeConfigurations("floatCache", floatCacheConfiguration);

  assertDefaultCopier(configHolder4.cacheConfiguration.getServiceConfigurations());

  MutableConfiguration<Long, Integer> integerCacheConfiguration  = new MutableConfiguration<>();
  integerCacheConfiguration.setTypes(Long.class, Integer.class);
  ConfigurationMerger.ConfigHolder<Long, Integer> configHolder5 = merger.mergeConfigurations("integerCache", integerCacheConfiguration);

  assertDefaultCopier(configHolder5.cacheConfiguration.getServiceConfigurations());

}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:38,代码来源:ConfigurationMergerTest.java


示例13: testXACacheWithXMLConfig

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@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[]
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:16,代码来源:XAGettingStarted.java


示例14: testSimpleConfig

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@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();
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:14,代码来源:XmlConfigTest.java


示例15: testTemplateConfigOverride

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@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"));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:11,代码来源:XmlConfigTest.java


示例16: testCanLoadXmlConfigValidForHA

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void testCanLoadXmlConfigValidForHA() {
  XmlConfiguration xmlConfiguration = new XmlConfiguration(getClass().getResource("/configs/cluster-ha.xml"));
  ClusteringServiceConfiguration config = ServiceUtils.findSingletonAmongst(ClusteringServiceConfiguration.class, xmlConfiguration
    .getServiceCreationConfigurations());
  assertThat(config.getClusterUri().toString(), containsString("example.com:9540,example.com:9640"));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:8,代码来源:TerracottaUriXmlTest.java


示例17: testFailsWithInvalidClusterUri

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void testFailsWithInvalidClusterUri() {
  try {
    new XmlConfiguration(getClass().getResource("/configs/cluster-invalid-uri.xml"));
  } catch (XmlConfigurationException e) {
    assertThat(e.getCause().getMessage(), containsString("not facet-valid with respect to pattern"));
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:9,代码来源:TerracottaUriXmlTest.java


示例18: testViaXml

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void testViaXml() throws Exception {
  final Configuration configuration = new XmlConfiguration(this.getClass().getResource(SIMPLE_CLUSTER_XML));
  final CacheManager cacheManager = CacheManagerBuilder.newCacheManager(configuration);

  assertThat(cacheManager, is(instanceOf(PersistentCacheManager.class)));

  cacheManager.init();

  final Cache<Long, String> cache = cacheManager.getCache("simple-cache", Long.class, String.class);
  assertThat(cache, is(not(nullValue())));

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


示例19: testGetUnknownCacheInvalidAttribute

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void testGetUnknownCacheInvalidAttribute() {
  try {
    new XmlConfiguration(this.getClass().getResource("/configs/unknown-cluster-cache-invalid-attribute.xml"));
    fail("Expected XmlConfigurationException");
  } catch(XmlConfigurationException xce) {
    Assert.assertThat(xce.getCause().getMessage(), endsWith("Attribute 'unit' is not allowed to appear in element 'tc:clustered'."));
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:10,代码来源:XmlUnknownCacheTest.java


示例20: testGetUnknownCacheInvalidElement

import org.ehcache.xml.XmlConfiguration; //导入依赖的package包/类
@Test
public void testGetUnknownCacheInvalidElement() {
  try {
    new XmlConfiguration(this.getClass().getResource("/configs/unknown-cluster-cache-invalid-element.xml"));
    fail("Expected XmlConfigurationException");
  } catch(XmlConfigurationException xce) {
    Assert.assertThat(xce.getCause().getMessage(), endsWith("Element 'tc:clustered' must have no character or element information item [children], because the type's content type is empty."));
  }
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:10,代码来源:XmlUnknownCacheTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SequenceFlow类代码示例发布时间:2022-05-22
下一篇:
Java GridFSUploadOptions类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap