Class NamedEventInterceptor<E extends Event<?>>

java.lang.Object
com.tangosol.net.events.NamedEventInterceptor<E>
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 Details

    • 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
      behavior - the behavior enacted upon discovering duplicate interceptors
      setEventTypes - the set of event types the interceptor is interested in
  • Method Details

    • getRegisteredName

      public String getRegisteredName()
      Return registered name of EventInterceptor.
      Returns:
      registered name of EventInterceptor
    • 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
    • getBehavior

      public RegistrationBehavior getBehavior()
      Return the RegistrationBehavior associated with this interceptor.
      Returns:
      the RegistrationBehavior associated with this interceptor
    • onEvent

      public void onEvent(E event)
      Perform necessary processing of the specified Event.
      Specified by:
      onEvent in interface EventInterceptor<E extends Event<?>>
      Parameters:
      event - the Event to be processed
      See Also:
    • introduceEventDispatcher

      public void introduceEventDispatcher(String sIdentifier, EventDispatcher dispatcher)
      Introduce and possibly bind this EventInterceptor to the specified EventDispatcher.

      Note that EventInterceptors are responsible for determining whether they should be registered with an EventDispatcher by calling EventDispatcher.addEventInterceptor(com.tangosol.net.events.EventInterceptor<E>).

      Specified by:
      introduceEventDispatcher in interface EventDispatcherAwareInterceptor<E extends Event<?>>
      Parameters:
      sIdentifier - the unique name identifying this interceptor
      dispatcher - the dispatcher being introduced
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • 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.