public final class CacheNotifierImpl<K,V> extends AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>> implements ClusterCacheNotifier<K,V>
Modifier and Type | Class and Description |
---|---|
protected static class |
CacheNotifierImpl.BaseCacheEntryListenerInvocation<K,V> |
protected class |
CacheNotifierImpl.CacheInvocationBuilder |
protected static class |
CacheNotifierImpl.ClusteredListenerInvocation<K,V>
This class is to be used with cluster listener invocations only when they have included current state.
|
protected class |
CacheNotifierImpl.DelegatingCacheInvocationBuilder |
protected class |
CacheNotifierImpl.NonClusteredListenerInvocation |
AbstractListenerImpl.AbstractInvocationBuilder, AbstractListenerImpl.ListenerInvocationImpl<A>
asyncProcessor, listenersMap, syncProcessor
Constructor and Description |
---|
CacheNotifierImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(Object listener)
Adds a listener to the component.
|
<C> void |
addListener(Object listener,
CacheEventFilter<? super K,? super V> filter,
CacheEventConverter<? super K,? super V,C> converter)
Registers a listener that will be notified on events that pass the filter condition.
|
<C> void |
addListener(Object listener,
CacheEventFilter<? super K,? super V> filter,
CacheEventConverter<? super K,? super V,C> converter,
ClassLoader classLoader)
Adds the listener using the provided filter converter and class loader.
|
void |
addListener(Object listener,
ClassLoader classLoader)
Adds a listener along with a class loader to use for the invocation
|
void |
addListener(Object listener,
KeyFilter<? super K> filter)
Adds a listener to the component.
|
void |
addListener(Object listener,
KeyFilter<? super K> filter,
ClassLoader classLoader)
Adds a listener to the component.
|
protected Map<Class<? extends Annotation>,Class<?>> |
getAllowedMethodAnnotations(Listener l) |
List<CacheEntryListenerInvocation<K,V>> |
getListenerCollectionForAnnotation(Class<? extends Annotation> annotation) |
protected Log |
getLog() |
boolean |
isNotificationAllowed(FlagAffectedCommand cmd,
List<CacheEntryListenerInvocation<K,V>> listeners) |
void |
notifyCacheEntriesEvicted(Collection<InternalCacheEntry<? extends K,? extends V>> entries,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntriesEvictedEvent event. |
void |
notifyCacheEntryActivated(K key,
V value,
boolean pre,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntryActivatedEvent event. |
void |
notifyCacheEntryCreated(K key,
V value,
Metadata metadata,
boolean pre,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntryCreatedEvent event. |
void |
notifyCacheEntryExpired(K key,
V value,
Metadata metadata,
InvocationContext ctx)
Notifies all registered listeners of a CacheEntryExpired event.
|
void |
notifyCacheEntryInvalidated(K key,
V value,
Metadata metadata,
boolean pre,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntryInvalidatedEvent event. |
void |
notifyCacheEntryLoaded(K key,
V value,
boolean pre,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntryLoadedEvent event. |
void |
notifyCacheEntryModified(K key,
V value,
Metadata metadata,
V previousValue,
Metadata previousMetadata,
boolean pre,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntryModifiedEvent event. |
void |
notifyCacheEntryPassivated(K key,
V value,
boolean pre,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntryPassivatedEvent event. |
void |
notifyCacheEntryRemoved(K key,
V previousValue,
Metadata previousMetadata,
boolean pre,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntryRemovedEvent event. |
void |
notifyCacheEntryVisited(K key,
V value,
boolean pre,
InvocationContext ctx,
FlagAffectedCommand command)
Notifies all registered listeners of a
CacheEntryVisitedEvent event. |
void |
notifyClusterListeners(Collection<? extends CacheEntryEvent<K,V>> events,
UUID uuid)
Method that is invoked on the node that has the given cluster listener that when registered generated the given
listenerId.
|
void |
notifyDataRehashed(ConsistentHash readCH,
ConsistentHash writeCH,
ConsistentHash unionCH,
int newTopologyId,
boolean pre) |
void |
notifyPartitionStatusChanged(AvailabilityMode mode,
boolean pre) |
void |
notifyTopologyChanged(CacheTopology oldTopology,
CacheTopology newTopology,
int newTopologyId,
boolean pre) |
void |
notifyTransactionCompleted(GlobalTransaction transaction,
boolean successful,
InvocationContext ctx)
Notifies all registered listeners of a transaction completion event.
|
void |
notifyTransactionRegistered(GlobalTransaction globalTransaction,
boolean isOriginLocal)
Notifies all registered listeners of a transaction registration event.
|
void |
removeListener(Object listener)
Removes a listener from the component.
|
protected Set<CacheEntryListenerInvocation<K,V>> |
removeListenerInvocation(Class<? extends Annotation> annotation,
Object listener) |
protected void |
resumeIfNeeded(Transaction transaction) |
Collection<DistributedCallable> |
retrieveClusterListenerCallablesToInstall()
This method is invoked so that this node can send the details required for a new node to be bootstrapped with
the existing cluster listeners that are already installed.
|
void |
setTypeConverter(TypeConverter typeConverter)
Set an optional converter to be used for converting the key/value of the event before notifying the listeners.
|
void |
start() |
void |
stop()
Removes all listeners from the notifier
|
protected Transaction |
suspendIfNeeded() |
getListeners, testListenerClassValidity, testListenerMethodValidity, validateAndAddListenerInvocations
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getListeners
public void start()
start
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
public void stop()
AbstractListenerImpl
stop
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
protected Log getLog()
getLog
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
public void setTypeConverter(TypeConverter typeConverter)
CacheNotifier
setTypeConverter
in interface CacheNotifier<K,V>
typeConverter
- the converter instance; can be null
protected Map<Class<? extends Annotation>,Class<?>> getAllowedMethodAnnotations(Listener l)
getAllowedMethodAnnotations
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
protected final Transaction suspendIfNeeded()
suspendIfNeeded
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
protected final void resumeIfNeeded(Transaction transaction)
resumeIfNeeded
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
public void notifyCacheEntryCreated(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntryCreatedEvent
event.notifyCacheEntryCreated
in interface CacheNotifier<K,V>
public void notifyCacheEntryModified(K key, V value, Metadata metadata, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntryModifiedEvent
event.notifyCacheEntryModified
in interface CacheNotifier<K,V>
public void notifyCacheEntryRemoved(K key, V previousValue, Metadata previousMetadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntryRemovedEvent
event.notifyCacheEntryRemoved
in interface CacheNotifier<K,V>
public void notifyCacheEntryVisited(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntryVisitedEvent
event.notifyCacheEntryVisited
in interface CacheNotifier<K,V>
public void notifyCacheEntriesEvicted(Collection<InternalCacheEntry<? extends K,? extends V>> entries, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntriesEvictedEvent
event.notifyCacheEntriesEvicted
in interface CacheNotifier<K,V>
public void notifyCacheEntryExpired(K key, V value, Metadata metadata, InvocationContext ctx)
CacheNotifier
notifyCacheEntryExpired
in interface CacheNotifier<K,V>
public void notifyCacheEntryInvalidated(K key, V value, Metadata metadata, boolean pre, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntryInvalidatedEvent
event.notifyCacheEntryInvalidated
in interface CacheNotifier<K,V>
public void notifyCacheEntryLoaded(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntryLoadedEvent
event.notifyCacheEntryLoaded
in interface CacheNotifier<K,V>
public void notifyCacheEntryActivated(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntryActivatedEvent
event.notifyCacheEntryActivated
in interface CacheNotifier<K,V>
public void notifyCacheEntryPassivated(K key, V value, boolean pre, InvocationContext ctx, FlagAffectedCommand command)
CacheNotifier
CacheEntryPassivatedEvent
event.notifyCacheEntryPassivated
in interface CacheNotifier<K,V>
public void notifyTransactionCompleted(GlobalTransaction transaction, boolean successful, InvocationContext ctx)
CacheNotifier
notifyTransactionCompleted
in interface CacheNotifier<K,V>
transaction
- the transaction that has just completedsuccessful
- if true, the transaction committed. If false, this is a rollback eventpublic void notifyTransactionRegistered(GlobalTransaction globalTransaction, boolean isOriginLocal)
CacheNotifier
notifyTransactionRegistered
in interface CacheNotifier<K,V>
public void notifyDataRehashed(ConsistentHash readCH, ConsistentHash writeCH, ConsistentHash unionCH, int newTopologyId, boolean pre)
notifyDataRehashed
in interface CacheNotifier<K,V>
public void notifyTopologyChanged(CacheTopology oldTopology, CacheTopology newTopology, int newTopologyId, boolean pre)
notifyTopologyChanged
in interface CacheNotifier<K,V>
public void notifyPartitionStatusChanged(AvailabilityMode mode, boolean pre)
notifyPartitionStatusChanged
in interface CacheNotifier<K,V>
public void notifyClusterListeners(Collection<? extends CacheEntryEvent<K,V>> events, UUID uuid)
ClusterCacheNotifier
notifyClusterListeners
in interface ClusterCacheNotifier<K,V>
public Collection<DistributedCallable> retrieveClusterListenerCallablesToInstall()
ClusterCacheNotifier
retrieveClusterListenerCallablesToInstall
in interface ClusterCacheNotifier<K,V>
public boolean isNotificationAllowed(FlagAffectedCommand cmd, List<CacheEntryListenerInvocation<K,V>> listeners)
public void addListener(Object listener)
Listenable
Listener
and
further to that, contain methods annotated appropriately, otherwise the listener will not be registered.
See the Listener
annotation for more information.
addListener
in interface Listenable
listener
- must not be null.public void addListener(Object listener, ClassLoader classLoader)
ClassLoaderAwareListenable
addListener
in interface ClassLoaderAwareListenable
public void addListener(Object listener, KeyFilter<? super K> filter, ClassLoader classLoader)
ClassLoaderAwareFilteringListenable
Listener
and
further to that, contain methods annotated appropriately, otherwise the listener will not be registered.
See the Listener
annotation for more information.
addListener
in interface ClassLoaderAwareFilteringListenable<K,V>
listener
- must not be null.classLoader
- class loaderpublic <C> void addListener(Object listener, CacheEventFilter<? super K,? super V> filter, CacheEventConverter<? super K,? super V,C> converter, ClassLoader classLoader)
addListener
in interface ClassLoaderAwareFilteringListenable<K,V>
C
- listener
- filter
- converter
- classLoader
- public List<CacheEntryListenerInvocation<K,V>> getListenerCollectionForAnnotation(Class<? extends Annotation> annotation)
getListenerCollectionForAnnotation
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
public void addListener(Object listener, KeyFilter<? super K> filter)
FilteringListenable
Listener
and
further to that, contain methods annotated appropriately, otherwise the listener will not be registered.
See the Listener
annotation for more information.
addListener
in interface FilteringListenable<K,V>
listener
- must not be null.public <C> void addListener(Object listener, CacheEventFilter<? super K,? super V> filter, CacheEventConverter<? super K,? super V,C> converter)
FilteringListenable
Some implementations may provide optimizations when a
CacheEventFilterConverter
is provided as both arguments
to the filter and converter arguments. Note the provided object must have reference equality ie. (==)
to be recognized. This allows for the filter and conversion step to take place in the same method call reducing
possible overhead.
addListener
in interface FilteringListenable<K,V>
C
- The type of the resultant value after being convertedlistener
- The listener to callback upon event notifications. Must not be null.filter
- The filter to see if the notification should be sent to the listener. Can be null.converter
- The converter to apply to the entry before being sent to the listener. Can be null.public void removeListener(Object listener)
Listenable
removeListener
in interface Listenable
removeListener
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
listener
- listener to remove. Must not be null.protected Set<CacheEntryListenerInvocation<K,V>> removeListenerInvocation(Class<? extends Annotation> annotation, Object listener)
removeListenerInvocation
in class AbstractListenerImpl<Event<K,V>,CacheEntryListenerInvocation<K,V>>
Copyright © 2023 JBoss, a division of Red Hat. All rights reserved.