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


Java XmlConfiguration类代码示例

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


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


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