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
  • Constructor Details

    • MapEventOutput

      public MapEventOutput(NamedCache<K,V> cache, boolean fLite)
      Construct MapEventOutput instance.
      Parameters:
      cache - the cache to register listener with
      fLite - the flag specifying whether to use lite events
  • Method Details

    • 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 interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class org.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 interface MapListener<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 interface MapListener<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 interface MapListener<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 name
      evt - 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 name
      evt - the MapEvent to convert
      Returns:
      an OutboundEvent with a given name and MapEvent data in JSON format
    • toString

      public String toString()
      Overrides:
      toString in class org.glassfish.jersey.server.ChunkedOutput<org.glassfish.jersey.media.sse.OutboundEvent>