Class HandlerAdapter
- java.lang.Object
-
- org.springframework.amqp.rabbit.listener.adapter.HandlerAdapter
-
public class HandlerAdapter extends Object
A wrapper for either anInvocableHandlerMethod
orDelegatingInvocableHandler
. All methods delegate to the underlying handler.- Since:
- 1.5
- Author:
- Gary Russell
-
-
Constructor Summary
Constructors Constructor Description HandlerAdapter(DelegatingInvocableHandler delegatingHandler)
Construct an instance with the provided delegating handler.HandlerAdapter(InvocableHandlerMethod invokerHandlerMethod)
Construct an instance with the provided method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getBean()
Get the bean from the handler method.InvocationResult
getInvocationResultFor(Object result, Object inboundPayload)
Build anInvocationResult
for the result and inbound payload.String
getMethodAsString(Object payload)
Get the method signature for the payload type viaMethod.toGenericString()
.Method
getMethodFor(Object payload)
Get the method for the payload type.Type
getReturnTypeFor(Object payload)
Return the return type for the method that will be chosen for this payload.InvocationResult
invoke(Message<?> message, Object... providedArgs)
Invoke the appropriate method for the payload.boolean
isAsyncReplies()
Return true if any handler method has an async reply type.
-
-
-
Constructor Detail
-
HandlerAdapter
public HandlerAdapter(InvocableHandlerMethod invokerHandlerMethod)
Construct an instance with the provided method.- Parameters:
invokerHandlerMethod
- the method.
-
HandlerAdapter
public HandlerAdapter(DelegatingInvocableHandler delegatingHandler)
Construct an instance with the provided delegating handler.- Parameters:
delegatingHandler
- the handler.
-
-
Method Detail
-
invoke
public InvocationResult invoke(@Nullable Message<?> message, Object... providedArgs) throws Exception
Invoke the appropriate method for the payload.- Parameters:
message
- the message.providedArgs
- additional arguments.- Returns:
- the invocation result.
- Throws:
Exception
- if one occurs.
-
getMethodAsString
public String getMethodAsString(Object payload)
Get the method signature for the payload type viaMethod.toGenericString()
.- Parameters:
payload
- the payload.- Returns:
- the method signature.
-
getMethodFor
public Method getMethodFor(Object payload)
Get the method for the payload type.- Parameters:
payload
- the payload.- Returns:
- the method.
- Since:
- 2.2.3
-
getReturnTypeFor
public Type getReturnTypeFor(Object payload)
Return the return type for the method that will be chosen for this payload.- Parameters:
payload
- the payload.- Returns:
- the return type, or null if no handler found.
- Since:
- 2.2.3
-
getBean
public Object getBean()
Get the bean from the handler method.- 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
-
getInvocationResultFor
@Nullable public InvocationResult getInvocationResultFor(Object result, Object inboundPayload)
Build anInvocationResult
for the result and inbound payload.- Parameters:
result
- the result.inboundPayload
- the payload.- Returns:
- the invocation result.
- Since:
- 2.1.7
-
-