本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
};
}