Class DelegatingInvocableHandler
- java.lang.Object
-
- org.springframework.kafka.listener.adapter.DelegatingInvocableHandler
-
public class DelegatingInvocableHandler extends java.lang.ObjectDelegates to anInvocableHandlerMethodbased on the message payload type. Matches a single, non-annotated parameter or one that is annotated withPayload. Matches must be unambiguous.- Author:
- Gary Russell
-
-
Constructor Summary
Constructors Constructor Description DelegatingInvocableHandler(java.util.List<org.springframework.messaging.handler.invocation.InvocableHandlerMethod> handlers, java.lang.Object bean, org.springframework.beans.factory.config.BeanExpressionResolver beanExpressionResolver, org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext)Construct an instance with the supplied handlers for the bean.DelegatingInvocableHandler(java.util.List<org.springframework.messaging.handler.invocation.InvocableHandlerMethod> handlers, org.springframework.messaging.handler.invocation.InvocableHandlerMethod defaultHandler, java.lang.Object bean, org.springframework.beans.factory.config.BeanExpressionResolver beanExpressionResolver, org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext)Construct an instance with the supplied handlers for the bean.DelegatingInvocableHandler(java.util.List<org.springframework.messaging.handler.invocation.InvocableHandlerMethod> handlers, org.springframework.messaging.handler.invocation.InvocableHandlerMethod defaultHandler, java.lang.Object bean, org.springframework.beans.factory.config.BeanExpressionResolver beanExpressionResolver, org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext, org.springframework.beans.factory.BeanFactory beanFactory)Construct an instance with the supplied handlers for the bean.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.springframework.messaging.handler.invocation.InvocableHandlerMethodfindHandlerForPayload(java.lang.Class<? extends java.lang.Object> payloadClass)java.lang.ObjectgetBean()Return the bean for this handler.protected org.springframework.messaging.handler.invocation.InvocableHandlerMethodgetHandlerForPayload(java.lang.Class<? extends java.lang.Object> payloadClass)Determine theInvocableHandlerMethodfor the provided type.java.lang.StringgetMethodNameFor(java.lang.Object payload)Return a string representation of the method that will be invoked for this payload.booleanhasDefaultHandler()java.lang.Objectinvoke(org.springframework.messaging.Message<?> message, java.lang.Object... providedArgs)Invoke the method with the given message.protected booleanmatchHandlerMethod(java.lang.Class<? extends java.lang.Object> payloadClass, org.springframework.messaging.handler.invocation.InvocableHandlerMethod handler)
-
-
-
Constructor Detail
-
DelegatingInvocableHandler
public DelegatingInvocableHandler(java.util.List<org.springframework.messaging.handler.invocation.InvocableHandlerMethod> handlers, java.lang.Object bean, org.springframework.beans.factory.config.BeanExpressionResolver beanExpressionResolver, org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext)Construct an instance with the supplied handlers for the bean.- Parameters:
handlers- the handlers.bean- the bean.beanExpressionResolver- the expression resolver.beanExpressionContext- the expression context.
-
DelegatingInvocableHandler
public DelegatingInvocableHandler(java.util.List<org.springframework.messaging.handler.invocation.InvocableHandlerMethod> handlers, @Nullable org.springframework.messaging.handler.invocation.InvocableHandlerMethod defaultHandler, java.lang.Object bean, org.springframework.beans.factory.config.BeanExpressionResolver beanExpressionResolver, org.springframework.beans.factory.config.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.1.3
-
DelegatingInvocableHandler
public DelegatingInvocableHandler(java.util.List<org.springframework.messaging.handler.invocation.InvocableHandlerMethod> handlers, @Nullable org.springframework.messaging.handler.invocation.InvocableHandlerMethod defaultHandler, java.lang.Object bean, org.springframework.beans.factory.config.BeanExpressionResolver beanExpressionResolver, org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext, @Nullable org.springframework.beans.factory.BeanFactory beanFactory)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.beanFactory- the bean factory.- Since:
- 2.1.11
-
-
Method Detail
-
getBean
public java.lang.Object getBean()
Return the bean for this handler.- Returns:
- the bean.
-
invoke
public java.lang.Object invoke(org.springframework.messaging.Message<?> message, java.lang.Object... providedArgs) throws java.lang.ExceptionInvoke the method with the given message.- Parameters:
message- the message.providedArgs- additional arguments.- Returns:
- the result of the invocation.
- Throws:
java.lang.Exception- raised if no suitable argument resolver can be found, or the method raised an exception.
-
getHandlerForPayload
protected org.springframework.messaging.handler.invocation.InvocableHandlerMethod getHandlerForPayload(java.lang.Class<? extends java.lang.Object> payloadClass)
Determine theInvocableHandlerMethodfor the provided type.- Parameters:
payloadClass- the payload class.- Returns:
- the handler.
-
findHandlerForPayload
protected org.springframework.messaging.handler.invocation.InvocableHandlerMethod findHandlerForPayload(java.lang.Class<? extends java.lang.Object> payloadClass)
-
matchHandlerMethod
protected boolean matchHandlerMethod(java.lang.Class<? extends java.lang.Object> payloadClass, org.springframework.messaging.handler.invocation.InvocableHandlerMethod handler)
-
getMethodNameFor
public java.lang.String getMethodNameFor(java.lang.Object payload)
Return a string representation of the method that will be invoked for this payload.- Parameters:
payload- the payload.- Returns:
- the method name.
-
hasDefaultHandler
public boolean hasDefaultHandler()
-
-