Source:
protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) { AbstractReplyProducingMessageHandler serviceActivator; if (AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) { final Object target = resolveTargetBeanFromMethodWithBeanAnnotation(method); serviceActivator = extractTypeIfPossible(target, AbstractReplyProducingMessageHandler.class); if (serviceActivator == null) { if (target instanceof MessageHandler) { return new ReplyProducingMessageHandlerWrapper((MessageHandler) target); } else { ResolvableType methodReturnType = ResolvableType.forMethodReturnType(method); if (Function.class.isAssignableFrom(methodReturnType.toClass()) || Consumer.class.isAssignableFrom(methodReturnType.toClass())) { Class<?> expectedPayloadType = methodReturnType.getGeneric(0).toClass(); serviceActivator = new ServiceActivatingHandler( new LambdaMessageProcessor(target, expectedPayloadType)); } else { serviceActivator = new ServiceActivatingHandler(target); } } } else { checkMessageHandlerAttributes(resolveTargetBeanName(method), annotations); return (MessageHandler) target; } } else { serviceActivator = new ServiceActivatingHandler(bean, method); } String requiresReply = MessagingAnnotationUtils.resolveAttribute(annotations, "requiresReply", String.class); if (StringUtils.hasText(requiresReply)) { serviceActivator.setRequiresReply(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(requiresReply))); } String isAsync = MessagingAnnotationUtils.resolveAttribute(annotations, "async", String.class); if (StringUtils.hasText(isAsync)) { serviceActivator.setAsync(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(isAsync))); } setOutputChannelIfPresent(annotations, serviceActivator); return serviceActivator; }

Target:
protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) { AbstractReplyProducingMessageHandler serviceActivator; if (AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) { final Object target = resolveTargetBeanFromMethodWithBeanAnnotation(method); serviceActivator = extractTypeIfPossible(target, AbstractReplyProducingMessageHandler.class); if (serviceActivator == null) { if (target instanceof MessageHandler) { return new ReplyProducingMessageHandlerWrapper((MessageHandler) target); } else { MessageProcessor<?> messageProcessor = buildLambdaMessageProcessorForBeanMethod(method, target); if (messageProcessor != null) { serviceActivator = new ServiceActivatingHandler(messageProcessor); } else { serviceActivator = new ServiceActivatingHandler(target); } } } else { checkMessageHandlerAttributes(resolveTargetBeanName(method), annotations); return (MessageHandler) target; } } else { serviceActivator = new ServiceActivatingHandler(bean, method); } String requiresReply = MessagingAnnotationUtils.resolveAttribute(annotations, "requiresReply", String.class); if (StringUtils.hasText(requiresReply)) { serviceActivator.setRequiresReply(resolveAttributeToBoolean(requiresReply)); } String isAsync = MessagingAnnotationUtils.resolveAttribute(annotations, "async", String.class); if (StringUtils.hasText(isAsync)) { serviceActivator.setAsync(resolveAttributeToBoolean(isAsync)); } setOutputChannelIfPresent(annotations, serviceActivator); return serviceActivator; }