Class NamedEventInterceptor<E extends Event<?>>

  • Type Parameters:
    E - the type of event
    All Implemented Interfaces:
    EventDispatcherAwareInterceptor<E>, EventInterceptor<E>

    public class NamedEventInterceptor<E extends Event<?>>
    extends Object
    implements EventDispatcherAwareInterceptor<E>
    A wrapper for EventInterceptors allowing additional metadata to be associated with the interceptor without augmenting the interceptor contract.

    This implementation will derive defaults for the values it is concerned with. These defaults are based on the presence of the Interceptor annotation, one or more Events annotations, or a generic type defined on the EventInterceptor class file. Once this class has been initialized, via constructors, it is immutable.

    There may be circumstances when the cost of deriving defaults may not be required thus a constructor is provided that avoids this initialization.

    Since:
    Coherence 12.1.2
    Author:
    hr/nsa/bo 2011.03.29
    • Constructor Detail

      • NamedEventInterceptor

        public NamedEventInterceptor​(EventInterceptor<E> interceptor)
        Construct a NamedEventInterceptor for the specified interceptor.
        Parameters:
        interceptor - the EventInterceptor
      • NamedEventInterceptor

        public NamedEventInterceptor​(String sName,
                                     EventInterceptor<E> interceptor)
        Construct a NamedEventInterceptor for the specified interceptor and unique identifier.
        Parameters:
        sName - the registered name of the wrapped interceptor
        interceptor - the EventInterceptor
      • NamedEventInterceptor

        public NamedEventInterceptor​(String sName,
                                     EventInterceptor<E> interceptor,
                                     RegistrationBehavior behavior)
        Construct a NamedEventInterceptor for the specified interceptor and unique identifier.
        Parameters:
        sName - the registered name of the wrapped interceptor
        interceptor - the EventInterceptor
        behavior - the behavior enacted upon discovering duplicate interceptors
      • NamedEventInterceptor

        public NamedEventInterceptor​(String sName,
                                     EventInterceptor<E> interceptor,
                                     String sCacheName,
                                     String sServiceName,
                                     Interceptor.Order order,
                                     RegistrationBehavior behavior)
        Construct a NamedEventInterceptor for the specified interceptor.
        Parameters:
        sName - the registered name of the wrapped interceptor
        interceptor - the EventInterceptor
        sCacheName - the name of the cache this interceptor is targeted to
        sServiceName - the name of the service this interceptor is targeted to
        order - whether this interceptor should be first in the chain of interceptors
        behavior - the behavior enacted upon discovering duplicate interceptors
      • NamedEventInterceptor

        public NamedEventInterceptor​(EventInterceptor<E> interceptor,
                                     NamedEventInterceptor<E> incptrNamed)
        Construct a NamedEventInterceptor for the specified interceptor using the provided NamedEventInterceptor as the source to clone from.
        Parameters:
        interceptor - the EventInterceptor
        incptrNamed - the NamedEventInterceptor to clone from
      • NamedEventInterceptor

        public NamedEventInterceptor​(String sName,
                                     EventInterceptor<E> interceptor,
                                     String sCacheName,
                                     String sServiceName,
                                     Interceptor.Order order,
                                     RegistrationBehavior behavior,
                                     Set<Enum> setEventTypes)
        Construct a NamedEventInterceptor for the specified interceptor.
        Parameters:
        sName - the registered name of the wrapped interceptor
        interceptor - the EventInterceptor
        sCacheName - the name of the cache this interceptor is targeted to
        sServiceName - the name of the service this interceptor is targeted to
        order - whether this interceptor should be first in the chain of interceptors
        setEventTypes - the set of event types the interceptor is interested in
        behavior - the behavior enacted upon discovering duplicate interceptors
    • Method Detail

      • getInterceptor

        public EventInterceptor<E> getInterceptor()
        Return the wrapped interceptor.
        Returns:
        the wrapped interceptor
      • getEventTypes

        public Set<Enum> getEventTypes()
        Return the set of event types this interceptor is concerned with.
        Returns:
        the set of event types this interceptor is concerned with
      • getServiceName

        public String getServiceName()
        Return the name of the service this interceptor should receive events from.
        Returns:
        the name of the service this interceptor should receive events from
      • getCacheName

        public String getCacheName()
        Return the name of the cache this interceptor should receive events from.
        Returns:
        the name of the cache this interceptor should receive events from
      • isFirst

        public boolean isFirst()
        Return whether this interceptor should request to be first in the chain of interceptors.
        Returns:
        whether this interceptor should request to be first in the chain of interceptors
      • getOrder

        public Interceptor.Order getOrder()
        Return the priority of this interceptor in the chain of interceptors.
        Returns:
        the priority of this interceptor in the chain of interceptors
      • isAcceptable

        public boolean isAcceptable​(EventDispatcher dispatcher)
        Determine whether the EventDispatcher should be accepted by this interceptor.
        Parameters:
        dispatcher - the EventDispatcher being introduced
      • generateName

        public String generateName()
        Generates a unique name for the interceptor. The unique name will be generated by appending a '$' following by an increasing integer.
        Returns:
        a unique name for the interceptor
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • ensureInitialized

        protected final void ensureInitialized()
        Based on the state of the NamedEventInterceptor populate any uninitialized values based on either an annotation being present or the class file's generic types.