Interface FilteringListenable<K,​V>

    • Method Detail

      • addListener

        void addListener​(java.lang.Object listener,
                         KeyFilter<? super K> filter)
        Adds a listener to the component. Typically, listeners would need to be annotated with Listener and further to that, contain methods annotated appropriately, otherwise the listener will not be registered.

        See the Listener annotation for more information.

        Parameters:
        listener - must not be null.
      • addListener

        <C> void addListener​(java.lang.Object listener,
                             CacheEventFilter<? super K,​? super V> filter,
                             CacheEventConverter<? super K,​? super V,​C> converter)
        Registers a listener that will be notified on events that pass the filter condition. The value presented in the notifications will be first converted using the provided converter if there is one.

        Some implementations may provide optimizations when a CacheEventFilterConverter is provided as both arguments to the filter and converter arguments. Note the provided object must have reference equality ie. (==) to be recognized. This allows for the filter and conversion step to take place in the same method call reducing possible overhead.

        Type Parameters:
        C - The type of the resultant value after being converted
        Parameters:
        listener - The listener to callback upon event notifications. Must not be null.
        filter - The filter to see if the notification should be sent to the listener. Can be null.
        converter - The converter to apply to the entry before being sent to the listener. Can be null.
        Throws:
        java.lang.NullPointerException - if the specified listener is null
      • addFilteredListener

        <C> void addFilteredListener​(java.lang.Object listener,
                                     CacheEventFilter<? super K,​? super V> filter,
                                     CacheEventConverter<? super K,​? super V,​C> converter,
                                     java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> filterAnnotations)
        Registers a listener limiting the cache-entry specific events only to annotations that are passed in as parameter.

        For example, if the listener passed in contains callbacks for CacheEntryCreated and CacheEntryModified, and filtered annotations contains only CacheEntryCreated, then the listener will be registered only for CacheEntryCreated callbacks.

        Callback filtering only applies to CacheEntryCreated, CacheEntryModified, CacheEntryRemoved and CacheEntryExpired annotations. If the listener contains other annotations, these are preserved.

        This methods enables dynamic registration of listener interests at runtime without the need to create several different listener classes.

        Type Parameters:
        C - The type of the resultant value after being converted
        Parameters:
        listener - The listener to callback upon event notifications. Must not be null.
        filter - The filter to see if the notification should be sent to the listener. Can be null.
        converter - The converter to apply to the entry before being sent to the listener. Can be null.
        filterAnnotations - cache-entry annotations to allow listener to be registered on. Must not be null.