Class MapEventOutput<K,V>
java.lang.Object
jakarta.ws.rs.core.GenericType<T>
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
ConstructorsConstructorDescriptionMapEventOutput(NamedCache<K, V> cache, boolean fLite) Construct MapEventOutput instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected org.glassfish.jersey.media.sse.OutboundEventcreateEvent(String sName, MapEvent<? extends K, ? extends V> evt) Convert MapEvent to JSON-based OutboundEvent that can be sent to the client.voidentryDeleted(MapEvent<K, V> evt) Invoked when a map entry has been removed.voidentryInserted(MapEvent<K, V> evt) Invoked when a map entry has been inserted.voidentryUpdated(MapEvent<K, V> evt) Invoked when a map entry has been updated.voidregister()Register this listener.Set the filter to listen on.Set the key to listen on.toString()protected voidUnregister this listener.protected voidwriteEvent(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, writeMethods inherited from class jakarta.ws.rs.core.GenericType
forInstance, getRawType, getTypeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>- Throws:
IOException
-
entryInserted
Description copied from interface:MapListenerInvoked when a map entry has been inserted.- Specified by:
entryInsertedin interfaceMapListener<K,V> - Parameters:
evt- the MapEvent carrying the insert information
-
entryUpdated
Description copied from interface:MapListenerInvoked when a map entry has been updated.- Specified by:
entryUpdatedin interfaceMapListener<K,V> - Parameters:
evt- the MapEvent carrying the update information
-
entryDeleted
Description copied from interface:MapListenerInvoked when a map entry has been removed.- Specified by:
entryDeletedin 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:
toStringin classorg.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>
-