Class AnnotationQueryHandlerAdapter<T>
java.lang.Object
org.axonframework.queryhandling.annotation.AnnotationQueryHandlerAdapter<T>
- All Implemented Interfaces:
MessageHandler<QueryMessage<?,,?>> QueryHandlerAdapter
public class AnnotationQueryHandlerAdapter<T>
extends Object
implements QueryHandlerAdapter, MessageHandler<QueryMessage<?,?>>
Adapter that turns any
@QueryHandler annotated bean into a MessageHandler
implementation. Each annotated method is subscribed as a QueryHandler at the QueryBus for the query type
specified by the parameter/return type of that method.- Since:
- 3.1
- Author:
- Marc Gathier
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotationQueryHandlerAdapter(T target) Initializes the adapter, forwarding call to the giventarget.AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory) Initializes the adapter, forwarding call to the giventarget, resolving parameters using the givenparameterResolverFactory.AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition) Initializes the adapter, forwarding call to the giventarget, resolving parameters using the givenparameterResolverFactoryand creating handlers usinghandlerDefinition. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanHandle(QueryMessage<?, ?> message) Indicates whether this handler can handle the given messagehandle(QueryMessage<?, ?> message) Handles the givenmessage.Subscribes the query handlers of thisQueryHandlerAdapterto the givenQueryBus.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.MessageHandler
canHandleType, getTargetType
-
Constructor Details
-
AnnotationQueryHandlerAdapter
Initializes the adapter, forwarding call to the giventarget.- Parameters:
target- the instance withQueryHandlerannotated methods
-
AnnotationQueryHandlerAdapter
Initializes the adapter, forwarding call to the giventarget, resolving parameters using the givenparameterResolverFactory.- Parameters:
target- the instance withQueryHandlerannotated methodsparameterResolverFactory- the parameter resolver factory to resolve handler parameters with
-
AnnotationQueryHandlerAdapter
public AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition) Initializes the adapter, forwarding call to the giventarget, resolving parameters using the givenparameterResolverFactoryand creating handlers usinghandlerDefinition.- Parameters:
target- the instance withQueryHandlerannotated methodsparameterResolverFactory- the parameter resolver factory to resolve handler parameters withhandlerDefinition- the handler definition used to create concrete handlers
-
-
Method Details
-
subscribe
Description copied from interface:QueryHandlerAdapterSubscribes the query handlers of thisQueryHandlerAdapterto the givenQueryBus.- Specified by:
subscribein interfaceQueryHandlerAdapter- Parameters:
queryBus- the query bus to subscribe- Returns:
- a
Registrationto unsubscribe thisQueryHandlerAdapter
-
handle
Description copied from interface:MessageHandlerHandles the givenmessage.- Specified by:
handlein interfaceMessageHandler<T>- Parameters:
message- The message to be processed.- Returns:
- The result of the message processing.
- Throws:
Exception- any exception that occurs during message handling
-
canHandle
Description copied from interface:MessageHandlerIndicates whether this handler can handle the given message- Specified by:
canHandlein interfaceMessageHandler<T>- Parameters:
message- The message to verify- Returns:
trueif this handler can handle the message, otherwisefalse
-