Class 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 bi-directional streaming of map events for a single cache.
    Since:
    20.06
    Author:
    Jonathan Knight 2019.12.03
    • Constructor Detail

      • 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 Detail

      • 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>
      • 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
      • 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.