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>
MapListener
implementation that converts CoherenceMapEvents
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
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 void
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.MapEventOutput
setFilter(Filter filter)
Set the filter to listen on.MapEventOutput
setKey(K key)
Set the key to listen on.String
toString()
protected void
unregister()
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 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:
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
public void entryInserted(MapEvent<K,V> evt)
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
public void entryUpdated(MapEvent<K,V> evt)
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
public void entryDeleted(MapEvent<K,V> evt)
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
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:
toString
in classorg.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>
-
-