Class MapListenerProxy

java.lang.Object
com.oracle.coherence.grpc.proxy.MapListenerProxy
All Implemented Interfaces:
MapListener<Object,Object>, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>, EventListener

public class MapListenerProxy extends Object implements io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>, MapListener<Object,Object>
A class to encapsulate bidirectional streaming of map events for a single cache.
Since:
20.06
Author:
Jonathan Knight 2019.12.03
  • Field Details

  • Constructor Details

    • MapListenerProxy

      public MapListenerProxy(NamedCacheService service, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerResponse> observer)
      Create a MapListenerProxy to handle aMapListener subscription to a cache.
      Parameters:
      service - the NamedCacheService to proxy
      observer - the StreamObserver to stream MapEvent instances to
  • Method Details

    • onNext

      public void onNext(com.oracle.coherence.grpc.MapListenerRequest request)
      Specified by:
      onNext in interface io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
    • onError

      public void onError(Throwable throwable)
      Specified by:
      onError in interface io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
    • onCompleted

      public void onCompleted()
      Specified by:
      onCompleted in interface io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
    • entryInserted

      public void entryInserted(MapEvent<Object,Object> mapEvent)
      Description copied from interface: MapListener
      Invoked when a map entry has been inserted.
      Specified by:
      entryInserted in interface MapListener<Object,Object>
      Parameters:
      mapEvent - the MapEvent carrying the insert information
    • entryUpdated

      public void entryUpdated(MapEvent<Object,Object> mapEvent)
      Description copied from interface: MapListener
      Invoked when a map entry has been updated.
      Specified by:
      entryUpdated in interface MapListener<Object,Object>
      Parameters:
      mapEvent - the MapEvent carrying the update information
    • entryDeleted

      public void entryDeleted(MapEvent<Object,Object> mapEvent)
      Description copied from interface: MapListener
      Invoked when a map entry has been removed.
      Specified by:
      entryDeleted in interface MapListener<Object,Object>
      Parameters:
      mapEvent - the MapEvent carrying the delete information
    • getDeactivationListener

      public MapListener<Object,Object> getDeactivationListener()
      Return the MapListenerProxy.DeactivationListener for this proxy.
      Returns:
      the MapListenerProxy.DeactivationListener for this proxy
    • onKeyRequest

      protected void onKeyRequest(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<?,?> trigger)
      Invoked when MapListenerRequest.RequestType is KEY.
      Parameters:
      request - the MapListenerRequest
      trigger - the MapTrigger
    • onFilterRequest

      protected void onFilterRequest(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<Binary,Binary> trigger)
      Invoked when MapListenerRequest.RequestType is KEY.
      Parameters:
      request - the MapListenerRequest
      trigger - the MapTrigger
    • addListener

      protected void addListener(Filter<?> filter, long filterId, boolean lite, boolean priming)
      Add this MapListenerProxy as a filter-based listener of the given NamedCache.
      Parameters:
      filter - the Filter to listen to
      filterId - the unique positive identifier of the Filter
      lite - true to add a "lite" listener
      priming - true if the listener is a priming listener
    • addListener

      protected void addListener(Object key, boolean lite, boolean priming)
      Add this MapListenerProxy as a key-based listener of the given NamedCache.
      Parameters:
      key - the key to listen to deserialized in Object form
      lite - true to add a "lite" listener
      priming - true if the listener is a priming listener
    • addListener

      protected void addListener(Object key, boolean lite, boolean priming, boolean register)
      Add this MapListenerProxy as a key-based listener of the given NamedCache.
      Parameters:
      key - the key to listen to deserialized in Object form
      lite - true to add a "lite" listener
      priming - true if the listener is a priming listener
      register - true if the listener should be added to the underlying cache
    • ensurePrimingListener

      protected MapListenerSupport.PrimingListener<Object,Object> ensurePrimingListener()
      Return the priming listener, or it not already cached, create it.
      Returns:
      the priming listener
    • onMapEvent

      protected void onMapEvent(MapEvent<?,?> event)
      Convert a MapEvent into a MapEventResponse and send it to the StreamObserver, converting theBinary key and values if required.
      Parameters:
      event - the event to send to the observer
    • createMapEventResponse

      protected com.oracle.coherence.grpc.MapEventResponse createMapEventResponse(MapEvent<?,?> mapEvent)
      Factory method to create new MapEventResponse instances using the information in the supplied MapEvent.
      Parameters:
      mapEvent - the MapEvent used to configure the newly created MapEventResponse
      Returns:
      a MapEventResponse created from the MapEvent
    • error

      protected com.oracle.coherence.grpc.MapListenerErrorResponse error(String uid, Throwable t)
      Create a MapListenerErrorResponse.
      Parameters:
      uid - the UID of the request
      t - the error that occurred
      Returns:
      a MapListenerErrorResponse.