Package com.oracle.coherence.cdi.events
Class EventObserverSupport.EventHandler<E extends Event<T>,T extends Enum<T>>
- java.lang.Object
-
- com.oracle.coherence.cdi.events.EventObserverSupport.EventHandler<E,T>
-
- Type Parameters:
E
- the type ofEvent
this interceptor acceptsT
- the enumeration of event types E supports
- All Implemented Interfaces:
EventDispatcherAwareInterceptor<E>
,EventInterceptor<E>
- Direct Known Subclasses:
EventObserverSupport.CacheLifecycleEventHandler
,EventObserverSupport.CoherenceLifecycleEventHandler
,EventObserverSupport.EntryEventHandler
,EventObserverSupport.EntryProcessorEventHandler
,EventObserverSupport.LifecycleEventHandler
,EventObserverSupport.ServiceEventHandler
,EventObserverSupport.SessionLifecycleEventHandler
- Enclosing class:
- EventObserverSupport
public abstract static class EventObserverSupport.EventHandler<E extends Event<T>,T extends Enum<T>> extends Object implements EventDispatcherAwareInterceptor<E>
Abstract base class for all observer-based interceptors.
-
-
Field Summary
Fields Modifier and Type Field Description protected EventObserverSupport.EventObserver<E>
m_observer
The observer method to delegate events to.protected EnumSet<T>
m_setTypes
A set of event types the observer is interested in.
-
Constructor Summary
Constructors Modifier Constructor Description protected
EventHandler(EventObserverSupport.EventObserver<E> observer, Class<T> classEventType)
ConstructEventHandler
instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addType(T type)
Add specified event type to a set of types this interceptor should handle.protected EnumSet<T>
eventTypes()
Create a final set of event types to register this interceptor for.protected String
getEventScope(E event)
Return the scope name of theConfigurableCacheFactory
the specified event was raised from.String
getId()
Return a unique identifier for this interceptor.String
getScopeName()
Return the name of the scope this interceptor should be registered with.void
introduceEventDispatcher(String sIdentifier, EventDispatcher dispatcher)
Introduce and possibly bind thisEventInterceptor
to the specifiedEventDispatcher
.protected abstract boolean
isApplicable(EventDispatcher dispatcher, String sScopeName)
Returntrue
if this interceptor should be registered with a specified dispatcher.void
onEvent(E event)
Perform necessary processing of the specifiedEvent
.protected String
removeScope(String sServiceName)
Remove the scope prefix from a specified service name.protected boolean
shouldFire(E event)
Returntrue
if the event should fire.
-
-
-
Constructor Detail
-
EventHandler
protected EventHandler(EventObserverSupport.EventObserver<E> observer, Class<T> classEventType)
ConstructEventHandler
instance.- Parameters:
observer
- the observer method to delegate events toclassEventType
- the class of event type enumeration
-
-
Method Detail
-
introduceEventDispatcher
public void introduceEventDispatcher(String sIdentifier, EventDispatcher dispatcher)
Description copied from interface:EventDispatcherAwareInterceptor
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<T>>
- Parameters:
sIdentifier
- the unique name identifying this interceptordispatcher
- the dispatcher being introduced
-
onEvent
public void onEvent(E event)
Description copied from interface:EventInterceptor
Perform necessary processing of the specifiedEvent
.- Specified by:
onEvent
in interfaceEventInterceptor<E extends Event<T>>
- Parameters:
event
- the Event to be processed- See Also:
Event.nextInterceptor()
-
getId
public String getId()
Return a unique identifier for this interceptor.- Returns:
- a unique identifier for this interceptor
-
isApplicable
protected abstract boolean isApplicable(EventDispatcher dispatcher, String sScopeName)
Returntrue
if this interceptor should be registered with a specified dispatcher.- Parameters:
dispatcher
- a dispatcher to register this interceptor withsScopeName
- a scope name the observer is interested in, ornull
for all scopes- Returns:
true
if this interceptor should be registered with a specified dispatcher;false
otherwise
-
shouldFire
protected boolean shouldFire(E event)
Returntrue
if the event should fire.This allows sub-classes to provide additional filtering logic and prevent the observer method notification from happening even after the Coherence server-side event is fired.
- Parameters:
event
- the event to check- Returns:
true
if the event should fire
-
getEventScope
protected String getEventScope(E event)
Return the scope name of theConfigurableCacheFactory
the specified event was raised from.- Parameters:
event
- the event to extract scope name from- Returns:
- the scope name
-
addType
protected void addType(T type)
Add specified event type to a set of types this interceptor should handle.- Parameters:
type
- the event type to add
-
eventTypes
protected EnumSet<T> eventTypes()
Create a final set of event types to register this interceptor for.- Returns:
- a final set of event types to register this interceptor for
-
getScopeName
public String getScopeName()
Return the name of the scope this interceptor should be registered with.- Returns:
- the name of the scope this interceptor should be registered with
-
-