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>
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 AutoCloseable
add(Listeners.ReadWriteListeners.ReadWriteListener<K,V> l)
Add a read-write listener, and return anAutoCloseable
instance that can be used to remove the listener registration.AutoCloseable
add(Listeners.WriteListeners.WriteListener<K,V> l)
Add a write-only listener, and return anAutoCloseable
instance that can be used to remove the listener registration.void
notifyOnCreate(CacheEntry entry)
Notify registeredListeners.ReadWriteListeners.ReadWriteListener
instances of the created entry.void
notifyOnModify(CacheEntry<K,V> entry, V previousValue, Metadata previousMetadata)
Notify registeredListeners.ReadWriteListeners.ReadWriteListener
instances of the modified entry passing the previous and new value.void
notifyOnRemove(EntryView.ReadEntryView<K,V> removed)
Notify registeredListeners.ReadWriteListeners.ReadWriteListener
instances of the removed entry passing in the removed entry.void
notifyOnWrite(CacheEntry<K,V> entry)
void
notifyOnWriteRemove(K key)
Notify registeredListeners.WriteListeners.WriteListener
instances of the written entry.AutoCloseable
onCreate(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a create event specific listener by passing in aConsumer
to be called back each time a new cache entry is created, passing in aEntryView.ReadEntryView
of that new entry.AutoCloseable
onModify(BiConsumer<EntryView.ReadEntryView<K,V>,EntryView.ReadEntryView<K,V>> f)
Add a modify/update event specific listener by passing in aBiConsumer
to be called back each time an entry is modified or updated, passing in aEntryView.ReadEntryView
of the previous entry as first parameter, and aEntryView.ReadEntryView
of the new value as second parameter.AutoCloseable
onRemove(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a remove event specific listener by passing in aConsumer
to be called back each time an entry is removed, passing in theEntryView.ReadEntryView
of the removed entry.AutoCloseable
onWrite(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a write event listener by passing in aConsumer
to 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.WriteListeners
Add a write-only listener, and return anAutoCloseable
instance that can be used to remove the listener registration.- Specified by:
add
in interfaceListeners.WriteListeners<K,V>
- Parameters:
l
- the write-only functional map event listener- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
add
public AutoCloseable add(Listeners.ReadWriteListeners.ReadWriteListener<K,V> l)
Description copied from interface:Listeners.ReadWriteListeners
Add a read-write listener, and return anAutoCloseable
instance that can be used to remove the listener registration.- Specified by:
add
in interfaceListeners.ReadWriteListeners<K,V>
- Parameters:
l
- the read-write functional map event listener- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
onCreate
public AutoCloseable onCreate(Consumer<EntryView.ReadEntryView<K,V>> f)
Description copied from interface:Listeners.ReadWriteListeners
Add a create event specific listener by passing in aConsumer
to be called back each time a new cache entry is created, passing in aEntryView.ReadEntryView
of 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:
onCreate
in interfaceListeners.ReadWriteListeners<K,V>
- Parameters:
f
- operation to be called each time a new cache entry is created- Returns:
- an
AutoCloseable
instance 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.ReadWriteListeners
Add a modify/update event specific listener by passing in aBiConsumer
to be called back each time an entry is modified or updated, passing in aEntryView.ReadEntryView
of the previous entry as first parameter, and aEntryView.ReadEntryView
of 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:
onModify
in 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.ReadEntryView
of the previous entry value, and the second parameter the newEntryView.ReadEntryView
- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
onRemove
public AutoCloseable onRemove(Consumer<EntryView.ReadEntryView<K,V>> f)
Description copied from interface:Listeners.ReadWriteListeners
Add a remove event specific listener by passing in aConsumer
to be called back each time an entry is removed, passing in theEntryView.ReadEntryView
of 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:
onRemove
in interfaceListeners.ReadWriteListeners<K,V>
- Parameters:
f
- operation to be called each time a new cache entry is removed, with the old cached entry'sEntryView.ReadEntryView
as parameter.- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
onWrite
public AutoCloseable onWrite(Consumer<EntryView.ReadEntryView<K,V>> f)
Description copied from interface:Listeners.WriteListeners
Add a write event listener by passing in aConsumer
to be called each time a cache entry is created, modified/updated or removed.For created or modified/updated events, the
EntryView.ReadEntryView
passed 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.ReadEntryView
passed in will represent an empty entry view, henceEntryView.ReadEntryView.find()
will return an emptyOptional
instance, andEntryView.ReadEntryView.get()
will throwNoSuchElementException
.- Specified by:
onWrite
in interfaceListeners.WriteListeners<K,V>
- Parameters:
f
- operation to be called each time a cache entry is written- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
notifyOnCreate
public void notifyOnCreate(CacheEntry entry)
Description copied from interface:FunctionalNotifier
Notify registeredListeners.ReadWriteListeners.ReadWriteListener
instances of the created entry.- Specified by:
notifyOnCreate
in interfaceFunctionalNotifier<K,V>
-
notifyOnModify
public void notifyOnModify(CacheEntry<K,V> entry, V previousValue, Metadata previousMetadata)
Description copied from interface:FunctionalNotifier
Notify registeredListeners.ReadWriteListeners.ReadWriteListener
instances of the modified entry passing the previous and new value.- Specified by:
notifyOnModify
in interfaceFunctionalNotifier<K,V>
-
notifyOnRemove
public void notifyOnRemove(EntryView.ReadEntryView<K,V> removed)
Description copied from interface:FunctionalNotifier
Notify registeredListeners.ReadWriteListeners.ReadWriteListener
instances of the removed entry passing in the removed entry.- Specified by:
notifyOnRemove
in interfaceFunctionalNotifier<K,V>
-
notifyOnWrite
public void notifyOnWrite(CacheEntry<K,V> entry)
- Specified by:
notifyOnWrite
in interfaceFunctionalNotifier<K,V>
-
notifyOnWriteRemove
public void notifyOnWriteRemove(K key)
Description copied from interface:FunctionalNotifier
Notify registeredListeners.WriteListeners.WriteListener
instances of the written entry.- Specified by:
notifyOnWriteRemove
in interfaceFunctionalNotifier<K,V>
-
-