Class Handler.Evaluator

java.lang.Object
org.jgrapes.core.annotation.Handler.Evaluator
All Implemented Interfaces:
HandlerDefinition.Evaluator
Enclosing class:
Handler

public static class Handler.Evaluator extends Object implements HandlerDefinition.Evaluator
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 Details

  • 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 a HandlerScope 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 interface HandlerDefinition.Evaluator
      Parameters:
      component - the component
      method - the annotated method
      channelReplacements - replacements for channel classes in the annotation’s channels element
      Returns:
      the scope or null if a handler for the method should not be created
    • priority

      public int priority(Annotation annotation)
      Description copied from interface: HandlerDefinition.Evaluator
      Returns the priority defined by the annotation
      Specified by:
      priority in interface HandlerDefinition.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 type Channel.

      Parameters:
      component - the component
      method - the name of the method that implements the handler
      eventValue - the event key that should be used for matching this handler with an event. This is equivalent to an events/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 a channels/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 a Channel, its default criterion is used for matching.
      priority - the priority of the handler
    • add

      public static void add(ComponentType component, String method, Object channelValue)
      Add a handler like add(ComponentType, String, Object, Object, int) but take the values for event and priority from the annotation.
      Parameters:
      component - the component
      method - the name of the method that implements the handler
      channelValue - the channel value that should be used for matching an event’s channel with this handler