Class FunctionalNotifierImpl<K,V>
- java.lang.Object
-
- org.infinispan.functional.impl.FunctionalNotifierImpl<K,V>
-
- All Implemented Interfaces:
FunctionalNotifier<K,V>,Listeners.ReadWriteListeners<K,V>,Listeners.WriteListeners<K,V>
@Experimental public final class FunctionalNotifierImpl<K,V> extends Object implements FunctionalNotifier<K,V>
- Since:
- 8.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.functional.Listeners.ReadWriteListeners
Listeners.ReadWriteListeners.ReadWriteListener<K,V>
-
Nested classes/interfaces inherited from interface org.infinispan.functional.Listeners.WriteListeners
Listeners.WriteListeners.WriteListener<K,V>
-
-
Constructor Summary
Constructors Constructor Description FunctionalNotifierImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AutoCloseableadd(Listeners.ReadWriteListeners.ReadWriteListener<K,V> l)Add a read-write listener, and return anAutoCloseableinstance that can be used to remove the listener registration.AutoCloseableadd(Listeners.WriteListeners.WriteListener<K,V> l)Add a write-only listener, and return anAutoCloseableinstance that can be used to remove the listener registration.voidnotifyOnCreate(CacheEntry entry)Notify registeredListeners.ReadWriteListeners.ReadWriteListenerinstances of the created entry.voidnotifyOnModify(CacheEntry<K,V> entry, V previousValue, Metadata previousMetadata)Notify registeredListeners.ReadWriteListeners.ReadWriteListenerinstances of the modified entry passing the previous and new value.voidnotifyOnRemove(EntryView.ReadEntryView<K,V> removed)Notify registeredListeners.ReadWriteListeners.ReadWriteListenerinstances of the removed entry passing in the removed entry.voidnotifyOnWrite(CacheEntry<K,V> entry)voidnotifyOnWriteRemove(K key)Notify registeredListeners.WriteListeners.WriteListenerinstances of the written entry.AutoCloseableonCreate(Consumer<EntryView.ReadEntryView<K,V>> f)Add a create event specific listener by passing in aConsumerto be called back each time a new cache entry is created, passing in aEntryView.ReadEntryViewof that new entry.AutoCloseableonModify(BiConsumer<EntryView.ReadEntryView<K,V>,EntryView.ReadEntryView<K,V>> f)Add a modify/update event specific listener by passing in aBiConsumerto be called back each time an entry is modified or updated, passing in aEntryView.ReadEntryViewof the previous entry as first parameter, and aEntryView.ReadEntryViewof the new value as second parameter.AutoCloseableonRemove(Consumer<EntryView.ReadEntryView<K,V>> f)Add a remove event specific listener by passing in aConsumerto be called back each time an entry is removed, passing in theEntryView.ReadEntryViewof the removed entry.AutoCloseableonWrite(Consumer<EntryView.ReadEntryView<K,V>> f)Add a write event listener by passing in aConsumerto be called each time a cache entry is created, modified/updated or removed.
-
-
-
Method Detail
-
add
public AutoCloseable add(Listeners.WriteListeners.WriteListener<K,V> l)
Description copied from interface:Listeners.WriteListenersAdd a write-only listener, and return anAutoCloseableinstance that can be used to remove the listener registration.- Specified by:
addin interfaceListeners.WriteListeners<K,V>- Parameters:
l- the write-only functional map event listener- Returns:
- an
AutoCloseableinstance that can be used to unregister the listener
-
add
public AutoCloseable add(Listeners.ReadWriteListeners.ReadWriteListener<K,V> l)
Description copied from interface:Listeners.ReadWriteListenersAdd a read-write listener, and return anAutoCloseableinstance that can be used to remove the listener registration.- Specified by:
addin interfaceListeners.ReadWriteListeners<K,V>- Parameters:
l- the read-write functional map event listener- Returns:
- an
AutoCloseableinstance that can be used to unregister the listener
-
onCreate
public AutoCloseable onCreate(Consumer<EntryView.ReadEntryView<K,V>> f)
Description copied from interface:Listeners.ReadWriteListenersAdd a create event specific listener by passing in aConsumerto be called back each time a new cache entry is created, passing in aEntryView.ReadEntryViewof that new entry.This method is shortcut for users who are only interested in create events. If interested in multiple event types, calling
Listeners.ReadWriteListeners.add(ReadWriteListener)is recommended instead.- Specified by:
onCreatein interfaceListeners.ReadWriteListeners<K,V>- Parameters:
f- operation to be called each time a new cache entry is created- Returns:
- an
AutoCloseableinstance that can be used to unregister the listener
-
onModify
public AutoCloseable onModify(BiConsumer<EntryView.ReadEntryView<K,V>,EntryView.ReadEntryView<K,V>> f)
Description copied from interface:Listeners.ReadWriteListenersAdd a modify/update event specific listener by passing in aBiConsumerto be called back each time an entry is modified or updated, passing in aEntryView.ReadEntryViewof the previous entry as first parameter, and aEntryView.ReadEntryViewof the new value as second parameter.This method is shortcut for users who are only interested in update events. If interested in multiple event types, calling
Listeners.ReadWriteListeners.add(ReadWriteListener)is recommended instead.- Specified by:
onModifyin interfaceListeners.ReadWriteListeners<K,V>- Parameters:
f- operation to be called each time a new cache entry is modified or updated, with the first parameter theEntryView.ReadEntryViewof the previous entry value, and the second parameter the newEntryView.ReadEntryView- Returns:
- an
AutoCloseableinstance that can be used to unregister the listener
-
onRemove
public AutoCloseable onRemove(Consumer<EntryView.ReadEntryView<K,V>> f)
Description copied from interface:Listeners.ReadWriteListenersAdd a remove event specific listener by passing in aConsumerto be called back each time an entry is removed, passing in theEntryView.ReadEntryViewof the removed entry.This method is shortcut for users who are only interested in remove events. If interested in multiple event types, calling
Listeners.ReadWriteListeners.add(ReadWriteListener)is recommended instead.- Specified by:
onRemovein interfaceListeners.ReadWriteListeners<K,V>- Parameters:
f- operation to be called each time a new cache entry is removed, with the old cached entry'sEntryView.ReadEntryViewas parameter.- Returns:
- an
AutoCloseableinstance that can be used to unregister the listener
-
onWrite
public AutoCloseable onWrite(Consumer<EntryView.ReadEntryView<K,V>> f)
Description copied from interface:Listeners.WriteListenersAdd a write event listener by passing in aConsumerto be called each time a cache entry is created, modified/updated or removed.For created or modified/updated events, the
EntryView.ReadEntryViewpassed in will represent the newly stored entry, hence implementations will not be available to differentiate between created events vs modified/updated events.For removed events,
EntryView.ReadEntryViewpassed in will represent an empty entry view, henceEntryView.ReadEntryView.find()will return an emptyOptionalinstance, andEntryView.ReadEntryView.get()will throwNoSuchElementException.- Specified by:
onWritein interfaceListeners.WriteListeners<K,V>- Parameters:
f- operation to be called each time a cache entry is written- Returns:
- an
AutoCloseableinstance that can be used to unregister the listener
-
notifyOnCreate
public void notifyOnCreate(CacheEntry entry)
Description copied from interface:FunctionalNotifierNotify registeredListeners.ReadWriteListeners.ReadWriteListenerinstances of the created entry.- Specified by:
notifyOnCreatein interfaceFunctionalNotifier<K,V>
-
notifyOnModify
public void notifyOnModify(CacheEntry<K,V> entry, V previousValue, Metadata previousMetadata)
Description copied from interface:FunctionalNotifierNotify registeredListeners.ReadWriteListeners.ReadWriteListenerinstances of the modified entry passing the previous and new value.- Specified by:
notifyOnModifyin interfaceFunctionalNotifier<K,V>
-
notifyOnRemove
public void notifyOnRemove(EntryView.ReadEntryView<K,V> removed)
Description copied from interface:FunctionalNotifierNotify registeredListeners.ReadWriteListeners.ReadWriteListenerinstances of the removed entry passing in the removed entry.- Specified by:
notifyOnRemovein interfaceFunctionalNotifier<K,V>
-
notifyOnWrite
public void notifyOnWrite(CacheEntry<K,V> entry)
- Specified by:
notifyOnWritein interfaceFunctionalNotifier<K,V>
-
notifyOnWriteRemove
public void notifyOnWriteRemove(K key)
Description copied from interface:FunctionalNotifierNotify registeredListeners.WriteListeners.WriteListenerinstances of the written entry.- Specified by:
notifyOnWriteRemovein interfaceFunctionalNotifier<K,V>
-
-