本文整理匯總了Java中org.infinispan.Cache.getListeners方法的典型用法代碼示例。如果您正苦於以下問題:Java Cache.getListeners方法的具體用法?Java Cache.getListeners怎麽用?Java Cache.getListeners使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.infinispan.Cache
的用法示例。
在下文中一共展示了Cache.getListeners方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getListeners
import org.infinispan.Cache; //導入方法依賴的package包/類
@Override
public Set<IGetUpdates<?, ?>> getListeners(String containerName,
String cacheName) {
EmbeddedCacheManager manager = this.cm;
Cache<Object,Object> c;
String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
if (manager == null) {
return null;
}
if (!manager.cacheExists(realCacheName)) {
return null;
}
c = manager.getCache(realCacheName);
Set<IGetUpdates<?, ?>> res = new HashSet<IGetUpdates<?, ?>>();
Set<Object> listeners = c.getListeners();
for (Object listener : listeners) {
if (listener instanceof CacheListenerContainer) {
CacheListenerContainer cl = (CacheListenerContainer) listener;
res.add(cl.whichListener());
}
}
return res;
}
示例2: removeListener
import org.infinispan.Cache; //導入方法依賴的package包/類
@Override
public void removeListener(String containerName, String cacheName,
IGetUpdates<?, ?> u) {
EmbeddedCacheManager manager = this.cm;
Cache<Object,Object> c;
String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
if (manager == null) {
return;
}
if (!manager.cacheExists(realCacheName)) {
return;
}
c = manager.getCache(realCacheName);
Set<Object> listeners = c.getListeners();
for (Object listener : listeners) {
if (listener instanceof CacheListenerContainer) {
CacheListenerContainer cl = (CacheListenerContainer) listener;
if (cl.whichListener() == u) {
c.removeListener(listener);
return;
}
}
}
}