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 ofEventthis 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_observerThe observer method to delegate events to.protected EnumSet<T>m_setTypesA set of event types the observer is interested in.
-
Constructor Summary
Constructors Modifier Constructor Description protectedEventHandler(EventObserverSupport.EventObserver<E> observer, Class<T> classEventType)ConstructEventHandlerinstance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddType(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 StringgetEventScope(E event)Return the scope name of theConfigurableCacheFactorythe specified event was raised from.StringgetId()Return a unique identifier for this interceptor.StringgetScopeName()Return the name of the scope this interceptor should be registered with.voidintroduceEventDispatcher(String sIdentifier, EventDispatcher dispatcher)Introduce and possibly bind thisEventInterceptorto the specifiedEventDispatcher.protected abstract booleanisApplicable(EventDispatcher dispatcher, String sScopeName)Returntrueif this interceptor should be registered with a specified dispatcher.voidonEvent(E event)Perform necessary processing of the specifiedEvent.protected StringremoveScope(String sServiceName)Remove the scope prefix from a specified service name.protected booleanshouldFire(E event)Returntrueif the event should fire.
-
-
-
Constructor Detail
-
EventHandler
protected EventHandler(EventObserverSupport.EventObserver<E> observer, Class<T> classEventType)
ConstructEventHandlerinstance.- 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:EventDispatcherAwareInterceptorIntroduce and possibly bind thisEventInterceptorto 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:
introduceEventDispatcherin 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:EventInterceptorPerform necessary processing of the specifiedEvent.- Specified by:
onEventin 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)
Returntrueif 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, ornullfor all scopes- Returns:
trueif this interceptor should be registered with a specified dispatcher;falseotherwise
-
shouldFire
protected boolean shouldFire(E event)
Returntrueif 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:
trueif the event should fire
-
getEventScope
protected String getEventScope(E event)
Return the scope name of theConfigurableCacheFactorythe 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
-
-