Class AnnotatedHandlerInspector<T>

java.lang.Object
org.axonframework.messaging.core.annotation.AnnotatedHandlerInspector<T>
Type Parameters:
T - The target type.

@Internal public class AnnotatedHandlerInspector<T> extends Object
Inspector for a message handling target of type T that uses annotations on the target to inspect the capabilities of the target.
Since:
3.0.0
Author:
Allard Buijze
  • Method Details

    • inspectType

      public static <T> AnnotatedHandlerInspector<T> inspectType(Class<T> handlerType)
      Create an inspector for given handlerType that uses a ClasspathParameterResolverFactory to resolve method parameters and ClasspathHandlerDefinition to create handlers.
      Type Parameters:
      T - the handler's type
      Parameters:
      handlerType - the target handler type
      Returns:
      a new inspector instance for the inspected class
    • inspectType

      public static <T> AnnotatedHandlerInspector<T> inspectType(Class<T> handlerType, MessageTypeResolver messageTypeResolver, ParameterResolverFactory parameterResolverFactory)
      Create an inspector for given handlerType that uses given parameterResolverFactory to resolve method parameters.
      Type Parameters:
      T - the handler's type
      Parameters:
      handlerType - the target handler type
      messageTypeResolver - the message type resolver used to derive the return type of the message returned by the MessageStream returned from uncovered MessageHandlers
      parameterResolverFactory - the resolver factory to use during detection
      Returns:
      a new inspector instance for the inspected class
    • inspectType

      public static <T> AnnotatedHandlerInspector<T> inspectType(Class<T> handlerType, MessageTypeResolver messageTypeResolver, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition)
      Create an inspector for given handlerType that uses given parameterResolverFactory to resolve method parameters and given handlerDefinition to create handlers.
      Type Parameters:
      T - the handler's type
      Parameters:
      handlerType - the target handler type
      messageTypeResolver - the message type resolver used to derive the return type of the message returned by the MessageStream returned from uncovered MessageHandlers
      parameterResolverFactory - the resolver factory to use during detection
      handlerDefinition - the handler definition used to create concrete handlers
      Returns:
      a new inspector instance for the inspected class
    • inspectType

      public static <T> AnnotatedHandlerInspector<T> inspectType(Class<T> handlerType, MessageTypeResolver messageTypeResolver, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition, Set<Class<? extends T>> declaredSubtypes)
      Create an inspector for given handlerType and its declaredSubtypes that uses given parameterResolverFactory to resolve method parameters and given handlerDefinition to create handlers.
      Type Parameters:
      T - the handler's type
      Parameters:
      handlerType - the target handler type
      messageTypeResolver - the message type resolver used to derive the return type of the message returned by the MessageStream returned from uncovered MessageHandlers
      parameterResolverFactory - the resolver factory to use during detection
      handlerDefinition - the handler definition used to create concrete handlers
      declaredSubtypes - the declared subtypes of this handlerType
      Returns:
      a new inspector instance for the inspected class
    • getHandlers

      public SortedSet<MessageHandlingMember<? super T>> getHandlers(Class<?> type)
      Returns a sorted set of detected members of given type that are capable of handling certain messages.
      Parameters:
      type - a type of inspected entity
      Returns:
      a sorted set of detected message handlers for given type
    • getUniqueHandlers

      public List<MessageHandlingMember<? super T>> getUniqueHandlers(Class<?> type, Class<? extends Message> messageType)
      Returns a list of detected members of given type, that can handle messages of messageType. When several members resolve to the same method signature - for example a supertype handler that is overridden or shadowed by a subtype - only the member declared by the most specific type is retained.
      Parameters:
      type - a type of inspected entity
      messageType - a message type the returned handlers must be able to handle
      Returns:
      a list of unique detected message handlers for given type, that can handle messages of messageType
    • chainedInterceptor

      public MessageHandlerInterceptorMemberChain<T> chainedInterceptor(Class<?> type)
      Returns an Interceptor Chain of annotated interceptor methods defined on the given type. The given chain will invoke all relevant interceptors in an order defined by the handler definition.
      Parameters:
      type - The type containing the handler definitions
      Returns:
      an interceptor chain that invokes the interceptor handlers defined on the inspected type
    • getAllHandlers

      public Map<Class<?>,SortedSet<MessageHandlingMember<? super T>>> getAllHandlers()
      Gets all handlers per type for inspected entity. Handlers are sorted based on HandlerComparator.
      Returns:
      a map of handlers per type
    • getAllInterceptors

      public Map<Class<?>,SortedSet<MessageHandlingMember<? super T>>> getAllInterceptors()
      Returns a Map of all registered interceptor methods per inspected type. Each entry contains the inspected type as key, and a SortedSet of interceptor methods defined on that type, in the order they are considered for invocation.
      Returns:
      a map of interceptors per type
    • resolveBehavior

      public <B> Optional<B> resolveBehavior(T target, Class<B> behaviorType)
      Resolves a behavior of the given behaviorType from the inspected target, on the target's behalf.

      This is the model's seam for exposing behaviors of an annotated handler. Currently it resolves a behavior the target implements directly. In the future, behaviors declared purely through annotations (for example an @SelfCheckpointing-style annotation that does not require the target to implement the interface) can be synthesised here on the target's behalf, without the wrapping component needing to change.

      Type Parameters:
      B - the behavior type
      Parameters:
      target - the inspected handler instance to resolve the behavior from
      behaviorType - the behavior type to resolve
      Returns:
      an Optional holding the resolved behavior, or empty if the target does not provide it
      Since:
      5.3.0