예제 #1
0
 @Override
 public void notifyCacheEntryModified(
     Object key,
     Object value,
     boolean created,
     boolean pre,
     InvocationContext ctx,
     FlagAffectedCommand command) {
   if (!cacheEntryModifiedListeners.isEmpty()) {
     boolean originLocal = ctx.isOriginLocal();
     EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_MODIFIED);
     e.setOriginLocal(originLocal);
     e.setValue(value);
     e.setPre(pre);
     e.setKey(key);
     // Even if CacheEntryCreatedEvent.getValue() has been added, to
     // avoid breaking old behaviour and make it easy to comply with
     // JSR-107 specification TCK, it's necessary to find out whether a
     // modification is the result of a cache entry being created or not.
     // This is needed because on JSR-107, a modification is only fired
     // when the entry is updated, and only one event is fired, so you
     // want to fire it when isPre=false.
     e.setCreated(created);
     setTx(ctx, e);
     for (ListenerInvocation listener : cacheEntryModifiedListeners) listener.invoke(e);
   }
 }
예제 #2
0
 @Override
 public void notifyCacheEntryPassivated(
     Object key, Object value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) {
   if (isNotificationAllowed(command, cacheEntryPassivatedListeners)) {
     EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_PASSIVATED);
     e.setPre(pre);
     e.setKey(key);
     e.setValue(value);
     for (ListenerInvocation listener : cacheEntryPassivatedListeners) listener.invoke(e);
   }
 }
예제 #3
0
 @Override
 public void notifyDataRehashed(
     ConsistentHash oldCH, ConsistentHash newCH, int newTopologyId, boolean pre) {
   if (!dataRehashedListeners.isEmpty()) {
     EventImpl<Object, Object> e = EventImpl.createEvent(cache, DATA_REHASHED);
     e.setPre(pre);
     e.setConsistentHashAtStart(oldCH);
     e.setConsistentHashAtEnd(newCH);
     e.setNewTopologyId(newTopologyId);
     for (ListenerInvocation listener : dataRehashedListeners) listener.invoke(e);
   }
 }
예제 #4
0
 @Override
 public void notifyCacheEntryActivated(
     Object key, Object value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) {
   if (isNotificationAllowed(command, cacheEntryActivatedListeners)) {
     boolean originLocal = ctx.isOriginLocal();
     EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_ACTIVATED);
     e.setOriginLocal(originLocal);
     e.setPre(pre);
     e.setKey(key);
     e.setValue(value);
     setTx(ctx, e);
     for (ListenerInvocation listener : cacheEntryActivatedListeners) listener.invoke(e);
   }
 }
예제 #5
0
 @Override
 public void notifyTopologyChanged(
     ConsistentHash oldConsistentHash,
     ConsistentHash newConsistentHash,
     int newTopologyId,
     boolean pre) {
   if (!topologyChangedListeners.isEmpty()) {
     EventImpl<Object, Object> e = EventImpl.createEvent(cache, TOPOLOGY_CHANGED);
     e.setPre(pre);
     e.setConsistentHashAtStart(oldConsistentHash);
     e.setConsistentHashAtEnd(newConsistentHash);
     e.setNewTopologyId(newTopologyId);
     for (ListenerInvocation listener : topologyChangedListeners) listener.invoke(e);
   }
 }
예제 #6
0
 @Override
 public void notifyCacheEntryCreated(
     Object key, Object value, boolean pre, InvocationContext ctx, FlagAffectedCommand command) {
   if (!cacheEntryCreatedListeners.isEmpty()) {
     boolean originLocal = ctx.isOriginLocal();
     EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_CREATED);
     e.setOriginLocal(originLocal);
     // Added capability to set cache entry created value in order
     // to avoid breaking behaviour of CacheEntryModifiedEvent.getValue()
     // when isPre=false.
     e.setValue(value);
     e.setPre(pre);
     e.setKey(key);
     setTx(ctx, e);
     for (ListenerInvocation listener : cacheEntryCreatedListeners) listener.invoke(e);
   }
 }