Package com.tangosol.net.events
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 forEventInterceptor
s 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 moreEvents
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 Summary
Constructors Constructor Description NamedEventInterceptor(EventInterceptor<E> interceptor)
Construct a NamedEventInterceptor for the specified interceptor.NamedEventInterceptor(EventInterceptor<E> interceptor, NamedEventInterceptor<E> incptrNamed)
Construct a NamedEventInterceptor for the specified interceptor using the provided NamedEventInterceptor as the source to clone from.NamedEventInterceptor(String sName, EventInterceptor<E> interceptor)
Construct a NamedEventInterceptor for the specified interceptor and unique identifier.NamedEventInterceptor(String sName, EventInterceptor<E> interceptor, RegistrationBehavior behavior)
Construct a NamedEventInterceptor for the specified interceptor and unique identifier.NamedEventInterceptor(String sName, EventInterceptor<E> interceptor, String sCacheName, String sServiceName, Interceptor.Order order, RegistrationBehavior behavior)
Construct a NamedEventInterceptor for the specified interceptor.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.boolean
equals(Object o)
String
generateName()
Generates a unique name for the interceptor.RegistrationBehavior
getBehavior()
Return theRegistrationBehavior
associated with this interceptor.String
getCacheName()
Return the name of the cache this interceptor should receive events from.Set<Enum>
getEventTypes()
Return the set of event types this interceptor is concerned with.EventInterceptor<E>
getInterceptor()
Return the wrapped interceptor.Interceptor.Order
getOrder()
Return the priority of this interceptor in the chain of interceptors.String
getRegisteredName()
Return registered name ofEventInterceptor
.String
getServiceName()
Return the name of the service this interceptor should receive events from.int
hashCode()
void
introduceEventDispatcher(String sIdentifier, EventDispatcher dispatcher)
Introduce and possibly bind thisEventInterceptor
to the specifiedEventDispatcher
.boolean
isAcceptable(EventDispatcher dispatcher)
Determine whether theEventDispatcher
should be accepted by this interceptor.boolean
isFirst()
Return whether this interceptor should request to be first in the chain of interceptors.void
onEvent(E event)
Perform necessary processing of the specifiedEvent
.String
toString()
-
-
-
Constructor Detail
-
NamedEventInterceptor
public NamedEventInterceptor(EventInterceptor<E> interceptor)
Construct a NamedEventInterceptor for the specified interceptor.- Parameters:
interceptor
- theEventInterceptor
-
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 interceptorinterceptor
- theEventInterceptor
-
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 interceptorinterceptor
- theEventInterceptor
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 interceptorinterceptor
- theEventInterceptor
sCacheName
- the name of the cache this interceptor is targeted tosServiceName
- the name of the service this interceptor is targeted toorder
- whether this interceptor should be first in the chain of interceptorsbehavior
- 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
- theEventInterceptor
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 interceptorinterceptor
- theEventInterceptor
sCacheName
- the name of the cache this interceptor is targeted tosServiceName
- the name of the service this interceptor is targeted toorder
- whether this interceptor should be first in the chain of interceptorssetEventTypes
- the set of event types the interceptor is interested inbehavior
- the behavior enacted upon discovering duplicate interceptors
-
-
Method Detail
-
getRegisteredName
public String getRegisteredName()
Return registered name ofEventInterceptor
.- 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 theRegistrationBehavior
associated with this interceptor.- Returns:
- the RegistrationBehavior associated with this interceptor
-
onEvent
public void onEvent(E event)
Perform necessary processing of the specifiedEvent
.- Specified by:
onEvent
in interfaceEventInterceptor<E extends Event<?>>
- Parameters:
event
- the Event to be processed- See Also:
Event.nextInterceptor()
-
introduceEventDispatcher
public void introduceEventDispatcher(String sIdentifier, EventDispatcher dispatcher)
Introduce and possibly bind thisEventInterceptor
to the specifiedEventDispatcher
.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 interfaceEventDispatcherAwareInterceptor<E extends Event<?>>
- Parameters:
sIdentifier
- the unique name identifying this interceptordispatcher
- the dispatcher being introduced
-
isAcceptable
public boolean isAcceptable(EventDispatcher dispatcher)
Determine whether theEventDispatcher
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
-
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.
-
-