public class AnnotationQueryHandlerAdapter<T> extends Object implements QueryHandlerAdapter, MessageHandler<QueryMessage<?,?>>
@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.Constructor and Description |
---|
AnnotationQueryHandlerAdapter(T target)
Initializes the adapter, forwarding call to the given
target . |
AnnotationQueryHandlerAdapter(T target,
ParameterResolverFactory parameterResolverFactory)
Initializes the adapter, forwarding call to the given
target , resolving parameters using the given parameterResolverFactory . |
AnnotationQueryHandlerAdapter(T target,
ParameterResolverFactory parameterResolverFactory,
HandlerDefinition handlerDefinition)
Initializes the adapter, forwarding call to the given
target , resolving parameters using the given parameterResolverFactory and creating handlers using handlerDefinition . |
Modifier and Type | Method and Description |
---|---|
boolean |
canHandle(QueryMessage<?,?> message)
Indicates whether this handler can handle the given message
|
Object |
handle(QueryMessage<?,?> message)
Handles the given
message . |
Registration |
subscribe(QueryBus queryBus)
Subscribes the query handlers of this
QueryHandlerAdapter to the given QueryBus . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canHandleType, getTargetType
public AnnotationQueryHandlerAdapter(T target)
target
.target
- the instance with QueryHandler
annotated methodspublic AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory)
target
, resolving parameters using the given parameterResolverFactory
.target
- the instance with QueryHandler
annotated methodsparameterResolverFactory
- the parameter resolver factory to resolve handler parameters withpublic AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition)
target
, resolving parameters using the given parameterResolverFactory
and creating handlers using handlerDefinition
.target
- the instance with QueryHandler
annotated methodsparameterResolverFactory
- the parameter resolver factory to resolve handler parameters withhandlerDefinition
- the handler definition used to create concrete handlerspublic Registration subscribe(@Nonnull QueryBus queryBus)
QueryHandlerAdapter
QueryHandlerAdapter
to the given QueryBus
.subscribe
in interface QueryHandlerAdapter
queryBus
- the query bus to subscribeRegistration
to unsubscribe this QueryHandlerAdapter
public Object handle(QueryMessage<?,?> message) throws Exception
MessageHandler
message
.handle
in interface MessageHandler<QueryMessage<?,?>>
message
- The message to be processed.Exception
- any exception that occurs during message handlingpublic boolean canHandle(QueryMessage<?,?> message)
MessageHandler
canHandle
in interface MessageHandler<QueryMessage<?,?>>
message
- The message to verifytrue
if this handler can handle the message, otherwise false
Copyright © 2010–2023. All rights reserved.