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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
add
(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 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.int
priority
(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 aHandlerScope
object.
-
Constructor Details
-
Evaluator
public Evaluator()
-
-
Method Details
-
scope
public HandlerScope scope(ComponentType component, Method method, HandlerDefinition.ChannelReplacements channelReplacements) Description copied from interface:HandlerDefinition.Evaluator
Returns the information about the events and channels handled by the handler that annotates the given method of the given comonent as aHandlerScope
object.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:
scope
in interfaceHandlerDefinition.Evaluator
- Parameters:
component
- the componentmethod
- the annotated methodchannelReplacements
- replacements for channel classes in the annotation’schannels
element- Returns:
- the scope or null if a handler for the method should not be created
-
priority
Description copied from interface:HandlerDefinition.Evaluator
Returns the priority defined by the annotation- Specified by:
priority
in 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
/namedEvents
parameter 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
/namedChannels
parameter 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
-