org.infinispan.Cache.getListeners()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.infinispan.Cache.getListeners()方法的一些代码示例,展示了Cache.getListeners()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.getListeners()方法的具体详情如下:
包路径:org.infinispan.Cache
类名称:Cache
方法名:getListeners

Cache.getListeners介绍

暂无

代码示例

代码示例来源:origin: org.opendaylight.controller/clustering.services-implementation

@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;
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testListenerRemoval() {
 cache.put("x", "y");
 AtomicInteger i = new AtomicInteger(0);
 int listenerSize = cache.getListeners().size();
 CacheListener l = new CacheListener(i);
 cache.addListener(l);
 assertEquals(listenerSize + 1, cache.getListeners().size());
 assert cache.getListeners().contains(l);
 assert 0 == i.get();
 cache.get("x");
 assert 1 == i.get();
 // remove the replListener
 cache.removeListener(l);
 assertEquals(listenerSize, cache.getListeners().size());
 i.set(0);
 assert 0 == i.get();
 cache.get("x");
 assert 0 == i.get();
}

代码示例来源:origin: org.opendaylight.controller/clustering.services-implementation

@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;
      }
    }
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testJoins() {
   int cache0Size = cache(0).getListeners().size();
   int cache1Size = cache(1).getListeners().size();

   cache(0).addListener(new NoOpListener());

   addClusterEnabledCacheManager(buildConfiguration());

   cache(0).addListener(new NoOpListener());

   waitForClusterToForm();

   // Now we verify the listener was actually added - since this is a DIST cache we also have the local listener
   // that sends remote and we added 2 of them
   assertEquals(cache0Size + 2, cache(0).getListeners().size());
   assertEquals(cache1Size + 2, cache(1).getListeners().size());
  }
}

相关文章