Package org.jgrapes.core.annotation
Class Handler.Evaluator
java.lang.Object
org.jgrapes.core.annotation.Handler.Evaluator
- All Implemented Interfaces:
HandlerDefinition.Evaluator
- Enclosing class:
Handler
This class provides the
Handler.Evaluator for the
Handler annotation provided by the core package.It implements the behavior as described for the annotation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadd(ComponentType component, String method, Object channelValue) Add a handler likeadd(ComponentType, String, Object, Object, int)but take the values for event and priority from the annotation.static voidadd(ComponentType component, String method, Object eventValue, Object channelValue, int priority) Adds the given method of the given component as a dynamic handler for a specific event and channel.intpriority(Annotation annotation) Returns the priority defined by the annotationscope(ComponentType component, Method method, HandlerDefinition.ChannelReplacements channelReplacements) Returns the information about the events and channels handled by the handler that annotates the given method of the given comonent as aHandlerScopeobject.
-
Constructor Details
-
Evaluator
public Evaluator()
-
-
Method Details
-
scope
public HandlerScope scope(ComponentType component, Method method, HandlerDefinition.ChannelReplacements channelReplacements) Description copied from interface:HandlerDefinition.EvaluatorReturns the information about the events and channels handled by the handler that annotates the given method of the given comonent as aHandlerScopeobject.This method is invoked during object initialization. It may return null if a handler is not supposed to be added for this method during initialization (dynamic handler, see
Handler.dynamic()).- Specified by:
scopein interfaceHandlerDefinition.Evaluator- Parameters:
component- the componentmethod- the annotated methodchannelReplacements- replacements for channel classes in the annotation’schannelselement- Returns:
- the scope or null if a handler for the method should not be created
-
priority
Description copied from interface:HandlerDefinition.EvaluatorReturns the priority defined by the annotation- Specified by:
priorityin interfaceHandlerDefinition.Evaluator- Parameters:
annotation- the annotation- Returns:
- the priority
-
add
public static void add(ComponentType component, String method, Object eventValue, Object channelValue, int priority) Adds the given method of the given component as a dynamic handler for a specific event and channel.The method with the given name must be annotated as dynamic handler and must have a single parameter of type
Event(or a derived type as appropriate for the event type to be handled). It can have an optional parameter of typeChannel.- Parameters:
component- the componentmethod- the name of the method that implements the handlereventValue- the event key that should be used for matching this handler with an event. This is equivalent to anevents/namedEventsparameter used with a single value in the handler annotation, but here all kinds of Objects are allowed as key values.channelValue- the channel value that should be used for matching an event’s channel with this handler. This is equivalent to achannels/namedChannelsparameter with a single value in the handler annotation, but here all kinds of Objects are allowed as values. As a convenience, if the actual object provided is aChannel, its default criterion is used for matching.priority- the priority of the handler
-
add
Add a handler likeadd(ComponentType, String, Object, Object, int)but take the values for event and priority from the annotation.- Parameters:
component- the componentmethod- the name of the method that implements the handlerchannelValue- the channel value that should be used for matching an event’s channel with this handler
-