K
- the type of key.V
- the type of value.public class CacheEventListenerAdaptor<K,V> extends Object implements CacheEventListener, CacheEntryListenerProvider<K,V>, NotifiableEventListener<CacheService>, ListenerWrapperEventFilter, IdentifiedDataSerializable
CacheEventListener
uses the adapter pattern for wrapping all cache event listener
types into a single listener.
JCache has multiple CacheEntryListener
sub-interfaces for each event type. This adapter
implementation delegates to the correct subtype using the event type.
Another responsibility of this implementation is filtering events by using the already configured event filters.
CacheEntryCreatedListener
,
CacheEntryUpdatedListener
,
CacheEntryRemovedListener
,
CacheEntryExpiredListener
,
CacheEntryEventFilter
Constructor and Description |
---|
CacheEventListenerAdaptor() |
CacheEventListenerAdaptor(ICache<K,V> source,
javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration,
SerializationService serializationService) |
Modifier and Type | Method and Description |
---|---|
boolean |
eval(Object event)
Returns
true if the event matches this filter. |
javax.cache.event.CacheEntryListener<K,V> |
getCacheEntryListener()
Gets wrapped
CacheEntryListener |
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
int |
getId()
Returns type identifier for this class.
|
Object |
getListener()
Gets the wrapped listener.
|
void |
handle(int type,
Collection<CacheEventData> keys,
int completionId) |
void |
handleEvent(Object eventObject)
Cache Event handling function.
|
void |
onDeregister(CacheService cacheService,
String serviceName,
String topic,
EventRegistration registration)
Called when this listener deregistered from
EventService . |
void |
onRegister(CacheService cacheService,
String serviceName,
String topic,
EventRegistration registration)
Called when this listener registered to
EventService . |
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
public javax.cache.event.CacheEntryListener<K,V> getCacheEntryListener()
CacheEntryListenerProvider
CacheEntryListener
getCacheEntryListener
in interface CacheEntryListenerProvider<K,V>
CacheEntryListener
public void handleEvent(Object eventObject)
CacheEventListener
handleEvent
in interface CacheEventListener
eventObject
- Event data object, can be one of CacheEventSet
or CacheEventData
classes.Event Types that can be handled.
public void handle(int type, Collection<CacheEventData> keys, int completionId)
public void onRegister(CacheService cacheService, String serviceName, String topic, EventRegistration registration)
NotifiableEventListener
EventService
.onRegister
in interface NotifiableEventListener<CacheService>
cacheService
- the service instance that event belongs toserviceName
- name of the service that event belongs totopic
- name of the topic that event belongs toregistration
- the EventRegistration
instance
that holds information about the registrationpublic void onDeregister(CacheService cacheService, String serviceName, String topic, EventRegistration registration)
NotifiableEventListener
EventService
.onDeregister
in interface NotifiableEventListener<CacheService>
cacheService
- the service instance that event belongs toserviceName
- name of the service that event belongs totopic
- name of the topic that event belongs toregistration
- the EventRegistration
instance
that holds information about the registrationpublic boolean eval(Object event)
EventFilter
true
if the event
matches this filter.eval
in interface EventFilter
public Object getListener()
ListenerWrapperEventFilter
getListener
in interface ListenerWrapperEventFilter
public int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
public int getId()
IdentifiedDataSerializable
getId
in interface IdentifiedDataSerializable
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.