Java Code Examples for org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver

The following examples show how to use org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
	ApplicationContext context = getApplicationContext();
	ConfigurableBeanFactory beanFactory = (context instanceof ConfigurableApplicationContext ?
			((ConfigurableApplicationContext) context).getBeanFactory() : null);

	List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();

	// Annotation-based argument resolution
	resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory));
	resolvers.add(new HeadersMethodArgumentResolver());
	resolvers.add(new DestinationVariableMethodArgumentResolver(this.conversionService));

	// Type-based argument resolution
	resolvers.add(new PrincipalMethodArgumentResolver());
	resolvers.add(new MessageMethodArgumentResolver(this.messageConverter));

	resolvers.addAll(getCustomArgumentResolvers());
	resolvers.add(new PayloadArgumentResolver(this.messageConverter, this.validator));

	return resolvers;
}
 
Example 2
protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
	ConfigurableBeanFactory beanFactory = (getApplicationContext() instanceof ConfigurableApplicationContext ?
			((ConfigurableApplicationContext) getApplicationContext()).getBeanFactory() : null);

	List<HandlerMethodArgumentResolver> resolvers = new ArrayList<HandlerMethodArgumentResolver>();

	// Annotation-based argument resolution
	resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory));
	resolvers.add(new HeadersMethodArgumentResolver());
	resolvers.add(new DestinationVariableMethodArgumentResolver(this.conversionService));

	// Type-based argument resolution
	resolvers.add(new PrincipalMethodArgumentResolver());
	resolvers.add(new MessageMethodArgumentResolver());

	resolvers.addAll(getCustomArgumentResolvers());
	resolvers.add(new PayloadArgumentResolver(this.messageConverter, this.validator));

	return resolvers;
}
 
Example 3
Source Project: spring-cloud-stream   Source File: AbstractBinderTests.java    License: Apache License 2.0 6 votes vote down vote up
private StreamListenerMessageHandler buildStreamListener(Class<?> handlerClass,
			String handlerMethodName, Class<?>... parameters) throws Exception {
		String channelName = "reply_" + System.nanoTime();

		this.applicationContext.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(this.applicationContext);
		handler.afterPropertiesSet();
//		context.refresh();
		return handler;
	}
 
Example 4
Source Project: spring-cloud-aws   Source File: QueueMessageHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected List<? extends HandlerMethodArgumentResolver> initArgumentResolvers() {
	List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>(
			getCustomArgumentResolvers());

	resolvers.add(new HeaderMethodArgumentResolver(null, null));
	resolvers.add(new SqsHeadersMethodArgumentResolver());

	resolvers.add(new NotificationSubjectArgumentResolver());
	resolvers.add(new AcknowledgmentHandlerMethodArgumentResolver(ACKNOWLEDGMENT));
	resolvers.add(new VisibilityHandlerMethodArgumentResolver(VISIBILITY));

	CompositeMessageConverter compositeMessageConverter = createPayloadArgumentCompositeConverter();
	resolvers.add(new NotificationMessageArgumentResolver(compositeMessageConverter));
	resolvers.add(new MessageMethodArgumentResolver(
			this.messageConverters.isEmpty() ? new StringMessageConverter()
					: new CompositeMessageConverter(this.messageConverters)));
	resolvers.add(new PayloadArgumentResolver(compositeMessageConverter,
			new NoOpValidator()));

	return resolvers;
}
 
Example 5
Source Project: rqueue   Source File: RqueueMessageHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected List<? extends HandlerMethodArgumentResolver> initArgumentResolvers() {
  List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>(getCustomArgumentResolvers());
  // Annotation-based argument resolution
  resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, getBeanFactory()));
  resolvers.add(new HeadersMethodArgumentResolver());

  // Type-based argument resolution
  resolvers.add(new PrincipalMethodArgumentResolver());
  resolvers.add(new MessageMethodArgumentResolver(messageConverter));
  resolvers.add(new PayloadArgumentResolver(messageConverter, null));

  return resolvers;
}