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


Java MutableConfiguration.addCacheEntryListenerConfiguration方法代码示例

本文整理汇总了Java中javax.cache.configuration.MutableConfiguration.addCacheEntryListenerConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java MutableConfiguration.addCacheEntryListenerConfiguration方法的具体用法?Java MutableConfiguration.addCacheEntryListenerConfiguration怎么用?Java MutableConfiguration.addCacheEntryListenerConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.cache.configuration.MutableConfiguration的用法示例。


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

示例1: testTemplateAddsListeners

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Test
public void testTemplateAddsListeners() throws Exception {
  CacheManager cacheManager = cachingProvider.getCacheManager(getClass().getResource("/ehcache-107-listeners.xml")
      .toURI(), getClass().getClassLoader());

  MutableConfiguration<String, String> configuration = new MutableConfiguration<>();
  configuration.setTypes(String.class, String.class);
  MutableCacheEntryListenerConfiguration<String, String> listenerConfiguration = new MutableCacheEntryListenerConfiguration<>(Test107CacheEntryListener::new, null, false, true);
  configuration.addCacheEntryListenerConfiguration(listenerConfiguration);

  Cache<String, String> cache = cacheManager.createCache("foos", configuration);
  cache.put("Hello", "Bonjour");

  assertThat(Test107CacheEntryListener.seen.size(), Matchers.is(1));
  assertThat(TestCacheEventListener.seen.size(), Matchers.is(1));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:17,代码来源:Eh107XmlIntegrationTest.java

示例2: extraSetup

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Override
protected MutableConfiguration<Integer, String> extraSetup(MutableConfiguration<Integer, String> cfg) {
  // cfg.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 5)));
  cacheEntryListenerServer = new CacheEntryListenerServer<>(10011, Integer.class, String.class);
  try {
    cacheEntryListenerServer.open();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  listener = new RecordingListener<>();
  cacheEntryListenerServer.addCacheEventListener(listener);
  CacheEntryListenerClient<Integer, String> clientListener =
    new CacheEntryListenerClient<>(cacheEntryListenerServer.getInetAddress(), cacheEntryListenerServer.getPort());
  boolean _isSynchronous = false;
  listenerConfiguration = new MutableCacheEntryListenerConfiguration<>(
    FactoryBuilder.factoryOf(clientListener), null, true, _isSynchronous);
  return cfg.addCacheEntryListenerConfiguration(listenerConfiguration);
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:19,代码来源:AdditionalCacheListenerTest.java

示例3: extraSetup

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Override
protected MutableConfiguration<Long, String> extraSetup(MutableConfiguration<Long, String> configuration) {
  cacheEntryListenerServer = new CacheEntryListenerServer<Long, String>(10011, Long.class, String.class);
  try {
    cacheEntryListenerServer.open();
  } catch (IOException e) {
    e.printStackTrace();
  }

  //establish and open a CacheEntryListenerServer to handle cache
  //cache entry events from a CacheEntryListenerClient
  listener = new MyCacheEntryListener<Long, String>();
  cacheEntryListenerServer.addCacheEventListener(listener);

  //establish a CacheEntryListenerClient that a Cache can use for CacheEntryListening
  //(via the CacheEntryListenerServer)
  CacheEntryListenerClient<Long, String> clientListener =
    new CacheEntryListenerClient<>(cacheEntryListenerServer.getInetAddress(), cacheEntryListenerServer.getPort());
  listenerConfiguration = new MutableCacheEntryListenerConfiguration<Long, String>(FactoryBuilder.factoryOf(clientListener), null, true, true);
  return configuration.addCacheEntryListenerConfiguration(listenerConfiguration);
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:22,代码来源:CacheListenerTest.java

示例4: extraSetup

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@Override
protected MutableConfiguration<Integer, Integer> extraSetup(MutableConfiguration<Integer, Integer> configuration) {
  listener = new CacheTestSupport.MyCacheEntryListener<Integer, Integer>();

  //establish a CacheEntryListenerClient that a Cache can use for CacheEntryListening
  //(via the CacheEntryListenerServer)

  listenerConfiguration =
    new MutableCacheEntryListenerConfiguration<>(FactoryBuilder.factoryOf(cacheEntryListerClient), null, true, true);
  cacheEntryListenerServer.addCacheEventListener(listener);
  return configuration.addCacheEntryListenerConfiguration(listenerConfiguration);
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:13,代码来源:CacheExpiryTest.java

示例5: getConfiguration

import javax.cache.configuration.MutableConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <C extends Configuration<K, V>> C getConfiguration(Class<C> _class) {
  if (CompleteConfiguration.class.isAssignableFrom(_class)) {
    MutableConfiguration<K, V> cfg = new MutableConfiguration<K, V>();
    cfg.setTypes(keyType, valueType);
    cfg.setStatisticsEnabled(jmxStatisticsEnabled);
    cfg.setManagementEnabled(jmxEnabled);
    cfg.setStoreByValue(storeByValue);
    Collection<CacheEntryListenerConfiguration<K,V>> _listenerConfigurations = eventHandling.getAllListenerConfigurations();
    for (CacheEntryListenerConfiguration<K,V> _listenerConfig : _listenerConfigurations) {
      cfg.addCacheEntryListenerConfiguration(_listenerConfig);
    }
    return (C) cfg;
  }
  return (C) new Configuration<K, V>() {
    @Override
    public Class<K> getKeyType() {
      return keyType;
    }

    @Override
    public Class<V> getValueType() {
      return valueType;
    }

    @Override
    public boolean isStoreByValue() {
      return storeByValue;
    }
  };
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:33,代码来源:JCacheAdapter.java


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