Class DelegatingInvocableHandler
java.lang.Object
org.springframework.amqp.rabbit.listener.adapter.DelegatingInvocableHandler
Delegates to an
InvocableHandlerMethod based on the message payload type.
Matches a single, non-annotated parameter or one that is annotated with
Payload. Matches must be
unambiguous.- Since:
- 1.5
- Author:
- Gary Russell, Artem Bilan
-
Constructor Summary
ConstructorsConstructorDescriptionDelegatingInvocableHandler(List<InvocableHandlerMethod> handlers, Object bean, BeanExpressionResolver beanExpressionResolver, BeanExpressionContext beanExpressionContext) Construct an instance with the supplied handlers for the bean.DelegatingInvocableHandler(List<InvocableHandlerMethod> handlers, InvocableHandlerMethod defaultHandler, Object bean, BeanExpressionResolver beanExpressionResolver, BeanExpressionContext beanExpressionContext) Construct an instance with the supplied handlers for the bean.DelegatingInvocableHandler(List<InvocableHandlerMethod> handlers, InvocableHandlerMethod defaultHandler, Object bean, BeanExpressionResolver beanExpressionResolver, BeanExpressionContext beanExpressionContext, Validator validator) Construct an instance with the supplied handlers for the bean. -
Method Summary
Modifier and TypeMethodDescriptionprotected InvocableHandlerMethodfindHandlerForPayload(Class<? extends Object> payloadClass) getBean()protected InvocableHandlerMethodgetHandlerForPayload(Class<? extends Object> payloadClass) getInvocationResultFor(Object result, Object inboundPayload) getMethodFor(Object payload) Return the method that will be invoked for this payload.getMethodNameFor(Object payload) Return a string representation of the method that will be invoked for this payload.booleanInvoke the method with the given message.booleanReturn true if any handler method has an async reply type.protected booleanmatchHandlerMethod(Class<? extends Object> payloadClass, InvocableHandlerMethod handler)
-
Constructor Details
-
DelegatingInvocableHandler
public DelegatingInvocableHandler(List<InvocableHandlerMethod> handlers, Object bean, BeanExpressionResolver beanExpressionResolver, BeanExpressionContext beanExpressionContext) Construct an instance with the supplied handlers for the bean.- Parameters:
handlers- the handlers.bean- the bean.beanExpressionResolver- the resolver.beanExpressionContext- the context.
-
DelegatingInvocableHandler
public DelegatingInvocableHandler(List<InvocableHandlerMethod> handlers, @Nullable InvocableHandlerMethod defaultHandler, Object bean, BeanExpressionResolver beanExpressionResolver, BeanExpressionContext beanExpressionContext) Construct an instance with the supplied handlers for the bean.- Parameters:
handlers- the handlers.defaultHandler- the default handler.bean- the bean.beanExpressionResolver- the resolver.beanExpressionContext- the context.- Since:
- 2.0.3
-
DelegatingInvocableHandler
public DelegatingInvocableHandler(List<InvocableHandlerMethod> handlers, @Nullable InvocableHandlerMethod defaultHandler, Object bean, BeanExpressionResolver beanExpressionResolver, BeanExpressionContext beanExpressionContext, @Nullable Validator validator) Construct an instance with the supplied handlers for the bean.- Parameters:
handlers- the handlers.defaultHandler- the default handler.bean- the bean.beanExpressionResolver- the resolver.beanExpressionContext- the context.validator- the validator.- Since:
- 2.0.3
-
-
Method Details
-
getBean
- Returns:
- the bean
-
isAsyncReplies
public boolean isAsyncReplies()Return true if any handler method has an async reply type.- Returns:
- the asyncReply.
- Since:
- 2.2.21
-
invoke
Invoke the method with the given message.- Parameters:
message- the message.providedArgs- additional arguments.- Returns:
- the result of the invocation.
- Throws:
Exception- raised if no suitable argument resolver can be found, or the method raised an exception.
-
getHandlerForPayload
- Parameters:
payloadClass- the payload class.- Returns:
- the handler.
-
findHandlerForPayload
-
matchHandlerMethod
protected boolean matchHandlerMethod(Class<? extends Object> payloadClass, InvocableHandlerMethod handler) -
getMethodNameFor
Return a string representation of the method that will be invoked for this payload.- Parameters:
payload- the payload.- Returns:
- the method name.
-
getMethodFor
Return the method that will be invoked for this payload.- Parameters:
payload- the payload.- Returns:
- the method.
- Since:
- 2.0
-
hasDefaultHandler
public boolean hasDefaultHandler() -
getInvocationResultFor
-