use of org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver in project spring-cloud-stream by spring-cloud.
the class AbstractBinderTests method buildStreamListener.
private StreamListenerMessageHandler buildStreamListener(Class<?> handlerClass, String handlerMethodName, Class<?>... parameters) throws Exception {
String channelName = "reply_" + System.nanoTime();
GenericApplicationContext context = new GenericApplicationContext();
context.getBeanFactory().registerSingleton(channelName, new QueueChannel());
Method m = ReflectionUtils.findMethod(handlerClass, handlerMethodName, parameters);
InvocableHandlerMethod method = new InvocableHandlerMethod(this, m);
HandlerMethodArgumentResolverComposite resolver = new HandlerMethodArgumentResolverComposite();
CompositeMessageConverterFactory factory = new CompositeMessageConverterFactory();
resolver.addResolver(new PayloadArgumentResolver(factory.getMessageConverterForAllRegistered()));
method.setMessageMethodArgumentResolvers(resolver);
Constructor<?> c = ReflectionUtils.accessibleConstructor(StreamListenerMessageHandler.class, InvocableHandlerMethod.class, boolean.class, String[].class);
StreamListenerMessageHandler handler = (StreamListenerMessageHandler) c.newInstance(method, false, new String[] {});
handler.setOutputChannelName(channelName);
handler.setBeanFactory(context);
handler.afterPropertiesSet();
context.refresh();
return handler;
}
Aggregations