Class DelegatingInvocableHandler

java.lang.Object
org.springframework.kafka.listener.adapter.DelegatingInvocableHandler

public class DelegatingInvocableHandler extends Object
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.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DelegatingInvocableHandler(List<org.springframework.messaging.handler.invocation.InvocableHandlerMethod> handlers, org.springframework.messaging.handler.invocation.InvocableHandlerMethod defaultHandler, Object bean, org.springframework.beans.factory.config.BeanExpressionResolver beanExpressionResolver, org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext, org.springframework.beans.factory.BeanFactory beanFactory, org.springframework.validation.Validator validator)
    Construct an instance with the supplied handlers for the bean.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.springframework.messaging.handler.invocation.InvocableHandlerMethod
    findHandlerForPayload(Class<? extends Object> payloadClass)
     
    Return the bean for this handler.
    protected org.springframework.messaging.handler.invocation.InvocableHandlerMethod
    getHandlerForPayload(Class<? extends Object> payloadClass)
    Determine the InvocableHandlerMethod for the provided type.
    Return a string representation of the method that will be invoked for this payload.
    boolean
     
    invoke(org.springframework.messaging.Message<?> message, Object... providedArgs)
    Invoke the method with the given message.
    protected boolean
    matchHandlerMethod(Class<? extends Object> payloadClass, org.springframework.messaging.handler.invocation.InvocableHandlerMethod handler)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DelegatingInvocableHandler

      public DelegatingInvocableHandler(List<org.springframework.messaging.handler.invocation.InvocableHandlerMethod> handlers, @Nullable org.springframework.messaging.handler.invocation.InvocableHandlerMethod defaultHandler, Object bean, @Nullable org.springframework.beans.factory.config.BeanExpressionResolver beanExpressionResolver, @Nullable org.springframework.beans.factory.config.BeanExpressionContext beanExpressionContext, @Nullable org.springframework.beans.factory.BeanFactory beanFactory, @Nullable org.springframework.validation.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.
      beanFactory - the bean factory.
      validator - the validator.
      Since:
      2.5.11
  • Method Details

    • getBean

      public Object getBean()
      Return the bean for this handler.
      Returns:
      the bean.
    • invoke

      public Object invoke(org.springframework.messaging.Message<?> message, Object... providedArgs) throws Exception
      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

      protected org.springframework.messaging.handler.invocation.InvocableHandlerMethod getHandlerForPayload(Class<? extends Object> payloadClass)
      Determine the InvocableHandlerMethod for the provided type.
      Parameters:
      payloadClass - the payload class.
      Returns:
      the handler.
    • findHandlerForPayload

      @Nullable protected org.springframework.messaging.handler.invocation.InvocableHandlerMethod findHandlerForPayload(Class<? extends Object> payloadClass)
    • matchHandlerMethod

      protected boolean matchHandlerMethod(Class<? extends Object> payloadClass, org.springframework.messaging.handler.invocation.InvocableHandlerMethod handler)
    • getMethodNameFor

      public String getMethodNameFor(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()