Class MapEventOutput<K,V>
- java.lang.Object
-
- javax.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>
MapListenerimplementation that converts CoherenceMapEventsinto 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
Constructors Constructor Description MapEventOutput(NamedCache<K,V> cache, boolean fLite)Construct MapEventOutput instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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.MapEventOutputsetFilter(Filter filter)Set the filter to listen on.MapEventOutputsetKey(K key)Set the key to listen on.StringtoString()protected voidunregister()Unregister 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, write
-
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 Detail
-
MapEventOutput
public MapEventOutput(NamedCache<K,V> cache, boolean fLite)
Construct MapEventOutput instance.- Parameters:
cache- the cache to register listener withfLite- the flag specifying whether to use lite events
-
-
Method Detail
-
setFilter
public MapEventOutput setFilter(Filter filter)
Set the filter to listen on.- Parameters:
filter- the filter to listen on- Returns:
- this MapEventOutput
-
setKey
public MapEventOutput setKey(K key)
Set the key to listen on.- Parameters:
key- the key to listen on- Returns:
- this MapEventOutput
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>- Throws:
IOException
-
entryInserted
public void entryInserted(MapEvent<K,V> evt)
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
public void entryUpdated(MapEvent<K,V> evt)
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
public void entryDeleted(MapEvent<K,V> evt)
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
protected void writeEvent(String sName, MapEvent<? extends K,? extends V> evt)
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
public String toString()
- Overrides:
toStringin classorg.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>
-
-