Class MapEventOutput<K,V>
java.lang.Object
jakarta.ws.rs.core.GenericType<org.glassfish.jersey.media.sse.OutboundEvent>
org.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>
org.glassfish.jersey.media.sse.EventOutput
com.tangosol.coherence.rest.events.MapEventOutput<K,V>
- All Implemented Interfaces:
MapListener<K,
,V> Closeable
,AutoCloseable
,EventListener
public class MapEventOutput<K,V>
extends org.glassfish.jersey.media.sse.EventOutput
implements MapListener<K,V>
MapListener
implementation that converts Coherence MapEvents
into Jersey Server Sent Events (SSE).- Author:
- as 2015.06.25
-
Field Summary
Fields inherited from interface com.tangosol.util.MapListener
ASYNCHRONOUS, SYNCHRONOUS, VERSION_AWARE
-
Constructor Summary
ConstructorDescriptionMapEventOutput
(NamedCache<K, V> cache, boolean fLite) Construct MapEventOutput instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected org.glassfish.jersey.media.sse.OutboundEvent
createEvent
(String sName, MapEvent<? extends K, ? extends V> evt) Convert MapEvent to JSON-based OutboundEvent that can be sent to the client.void
entryDeleted
(MapEvent<K, V> evt) Invoked when a map entry has been removed.void
entryInserted
(MapEvent<K, V> evt) Invoked when a map entry has been inserted.void
entryUpdated
(MapEvent<K, V> evt) Invoked when a map entry has been updated.void
register()
Register this listener.Set the filter to listen on.Set the key to listen on.toString()
protected void
Unregister this listener.protected void
writeEvent
(String sName, MapEvent<? extends K, ? extends V> evt) Write single event to this EventOutput.Methods inherited from class org.glassfish.jersey.server.ChunkedOutput
equals, flushQueue, hashCode, isClosed, onClose, write
Methods inherited from class jakarta.ws.rs.core.GenericType
forInstance, getRawType, getType
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.tangosol.util.MapListener
characteristics, isAsynchronous, isSynchronous, isVersionAware, synchronous
-
Constructor Details
-
MapEventOutput
Construct MapEventOutput instance.- Parameters:
cache
- the cache to register listener withfLite
- the flag specifying whether to use lite events
-
-
Method Details
-
setFilter
Set the filter to listen on.- Parameters:
filter
- the filter to listen on- Returns:
- this MapEventOutput
-
setKey
Set the key to listen on.- Parameters:
key
- the key to listen on- Returns:
- this MapEventOutput
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classorg.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>
- Throws:
IOException
-
entryInserted
Description copied from interface:MapListener
Invoked when a map entry has been inserted.- Specified by:
entryInserted
in interfaceMapListener<K,
V> - Parameters:
evt
- the MapEvent carrying the insert information
-
entryUpdated
Description copied from interface:MapListener
Invoked when a map entry has been updated.- Specified by:
entryUpdated
in interfaceMapListener<K,
V> - Parameters:
evt
- the MapEvent carrying the update information
-
entryDeleted
Description copied from interface:MapListener
Invoked when a map entry has been removed.- Specified by:
entryDeleted
in interfaceMapListener<K,
V> - Parameters:
evt
- the MapEvent carrying the delete information
-
register
public void register()Register this listener. -
unregister
protected void unregister()Unregister this listener. -
writeEvent
Write single event to this EventOutput.- Parameters:
sName
- the event nameevt
- the event to write
-
createEvent
protected org.glassfish.jersey.media.sse.OutboundEvent createEvent(String sName, MapEvent<? extends K, ? extends V> evt) Convert MapEvent to JSON-based OutboundEvent that can be sent to the client.- Parameters:
sName
- the event nameevt
- the MapEvent to convert- Returns:
- an OutboundEvent with a given name and MapEvent data in JSON format
-
toString
- Overrides:
toString
in classorg.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>
-