org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler Java Examples
The following examples show how to use
org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler.
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
Source File: AbstractMessageBrokerConfiguration.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Bean public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler() { SimpAnnotationMethodMessageHandler handler = createAnnotationMethodMessageHandler(); handler.setDestinationPrefixes(getBrokerRegistry().getApplicationDestinationPrefixes()); handler.setMessageConverter(brokerMessageConverter()); handler.setValidator(simpValidator()); List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<HandlerMethodArgumentResolver>(); addArgumentResolvers(argumentResolvers); handler.setCustomArgumentResolvers(argumentResolvers); List<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<HandlerMethodReturnValueHandler>(); addReturnValueHandlers(returnValueHandlers); handler.setCustomReturnValueHandlers(returnValueHandlers); PathMatcher pathMatcher = this.getBrokerRegistry().getPathMatcher(); if (pathMatcher != null) { handler.setPathMatcher(pathMatcher); } return handler; }
Example #2
Source File: AbstractMessageBrokerConfiguration.java From spring-analysis-note with MIT License | 6 votes |
@Bean public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler() { SimpAnnotationMethodMessageHandler handler = createAnnotationMethodMessageHandler(); handler.setDestinationPrefixes(getBrokerRegistry().getApplicationDestinationPrefixes()); handler.setMessageConverter(brokerMessageConverter()); handler.setValidator(simpValidator()); List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>(); addArgumentResolvers(argumentResolvers); handler.setCustomArgumentResolvers(argumentResolvers); List<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<>(); addReturnValueHandlers(returnValueHandlers); handler.setCustomReturnValueHandlers(returnValueHandlers); PathMatcher pathMatcher = getBrokerRegistry().getPathMatcher(); if (pathMatcher != null) { handler.setPathMatcher(pathMatcher); } return handler; }
Example #3
Source File: MessageBrokerBeanDefinitionParserTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void customArgumentAndReturnValueTypes() { loadBeanDefinitions("websocket-config-broker-custom-argument-and-return-value-types.xml"); SimpAnnotationMethodMessageHandler handler = this.appContext.getBean(SimpAnnotationMethodMessageHandler.class); List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers(); assertEquals(2, customResolvers.size()); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(0))); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(1))); List<HandlerMethodReturnValueHandler> customHandlers = handler.getCustomReturnValueHandlers(); assertEquals(2, customHandlers.size()); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(0))); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(1))); }
Example #4
Source File: MessageBrokerBeanDefinitionParserTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void customArgumentAndReturnValueTypes() { loadBeanDefinitions("websocket-config-broker-custom-argument-and-return-value-types.xml"); SimpAnnotationMethodMessageHandler handler = this.appContext.getBean(SimpAnnotationMethodMessageHandler.class); List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers(); assertEquals(2, customResolvers.size()); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(0))); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(1))); List<HandlerMethodReturnValueHandler> customHandlers = handler.getCustomReturnValueHandlers(); assertEquals(2, customHandlers.size()); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(0))); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(1))); }
Example #5
Source File: AbstractMessageBrokerConfiguration.java From java-technology-stack with MIT License | 6 votes |
@Bean public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler() { SimpAnnotationMethodMessageHandler handler = createAnnotationMethodMessageHandler(); handler.setDestinationPrefixes(getBrokerRegistry().getApplicationDestinationPrefixes()); handler.setMessageConverter(brokerMessageConverter()); handler.setValidator(simpValidator()); List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>(); addArgumentResolvers(argumentResolvers); handler.setCustomArgumentResolvers(argumentResolvers); List<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<>(); addReturnValueHandlers(returnValueHandlers); handler.setCustomReturnValueHandlers(returnValueHandlers); PathMatcher pathMatcher = getBrokerRegistry().getPathMatcher(); if (pathMatcher != null) { handler.setPathMatcher(pathMatcher); } return handler; }
Example #6
Source File: MessageBrokerBeanDefinitionParserTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void customArgumentAndReturnValueTypes() { loadBeanDefinitions("websocket-config-broker-custom-argument-and-return-value-types.xml"); SimpAnnotationMethodMessageHandler handler = this.appContext.getBean(SimpAnnotationMethodMessageHandler.class); List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers(); assertEquals(2, customResolvers.size()); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(0))); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(1))); List<HandlerMethodReturnValueHandler> customHandlers = handler.getCustomReturnValueHandlers(); assertEquals(2, customHandlers.size()); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(0))); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(1))); }
Example #7
Source File: MessageBrokerConfigurationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void customArgumentAndReturnValueTypes() throws Exception { SimpAnnotationMethodMessageHandler handler = this.customContext.getBean(SimpAnnotationMethodMessageHandler.class); List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers(); assertEquals(1, customResolvers.size()); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(0))); List<HandlerMethodReturnValueHandler> customHandlers = handler.getCustomReturnValueHandlers(); assertEquals(1, customHandlers.size()); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(0))); }
Example #8
Source File: SimpAnnotationMethodMessageHandler.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() { List<HandlerMethodReturnValueHandler> handlers = new ArrayList<HandlerMethodReturnValueHandler>(); // Single-purpose return value types handlers.add(new ListenableFutureReturnValueHandler()); if (completableFuturePresent) { handlers.add(new CompletableFutureReturnValueHandler()); } // Annotation-based return value types SendToMethodReturnValueHandler sth = new SendToMethodReturnValueHandler(this.brokerTemplate, true); sth.setHeaderInitializer(this.headerInitializer); handlers.add(sth); SubscriptionMethodReturnValueHandler sh = new SubscriptionMethodReturnValueHandler(this.clientMessagingTemplate); sh.setHeaderInitializer(this.headerInitializer); handlers.add(sh); // custom return value types handlers.addAll(getCustomReturnValueHandlers()); // catch-all sth = new SendToMethodReturnValueHandler(this.brokerTemplate, false); sth.setHeaderInitializer(this.headerInitializer); handlers.add(sth); return handlers; }
Example #9
Source File: MessageBrokerConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void customArgumentAndReturnValueTypes() { ApplicationContext context = loadConfig(CustomConfig.class); SimpAnnotationMethodMessageHandler handler = context.getBean(SimpAnnotationMethodMessageHandler.class); List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers(); assertEquals(1, customResolvers.size()); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(0))); List<HandlerMethodReturnValueHandler> customHandlers = handler.getCustomReturnValueHandlers(); assertEquals(1, customHandlers.size()); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(0))); }
Example #10
Source File: SimpAnnotationMethodMessageHandler.java From java-technology-stack with MIT License | 5 votes |
@Override protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() { List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>(); // Single-purpose return value types handlers.add(new ListenableFutureReturnValueHandler()); handlers.add(new CompletableFutureReturnValueHandler()); handlers.add(new ReactiveReturnValueHandler()); // Annotation-based return value types SendToMethodReturnValueHandler sendToHandler = new SendToMethodReturnValueHandler(this.brokerTemplate, true); sendToHandler.setHeaderInitializer(this.headerInitializer); handlers.add(sendToHandler); SubscriptionMethodReturnValueHandler subscriptionHandler = new SubscriptionMethodReturnValueHandler(this.clientMessagingTemplate); subscriptionHandler.setHeaderInitializer(this.headerInitializer); handlers.add(subscriptionHandler); // Custom return value types handlers.addAll(getCustomReturnValueHandlers()); // Catch-all sendToHandler = new SendToMethodReturnValueHandler(this.brokerTemplate, false); sendToHandler.setHeaderInitializer(this.headerInitializer); handlers.add(sendToHandler); return handlers; }
Example #11
Source File: QueueMessageHandlerTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
private AbstractBeanDefinition getQueueMessageHandlerBeanDefinition() { BeanDefinitionBuilder queueMessageHandlerBeanDefinitionBuilder = BeanDefinitionBuilder .rootBeanDefinition(QueueMessageHandler.class); ManagedList<HandlerMethodReturnValueHandler> returnValueHandlers = new ManagedList<>( 1); returnValueHandlers .add(new SendToHandlerMethodReturnValueHandler(this.messageTemplate)); queueMessageHandlerBeanDefinitionBuilder.addPropertyValue("returnValueHandlers", returnValueHandlers); return queueMessageHandlerBeanDefinitionBuilder.getBeanDefinition(); }
Example #12
Source File: QueueMessageHandlerTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void receiveMessage_withCustomReturnValueHandlers_shouldCallThemBeforeTheDefaultOnes() throws Exception { // Arrange StaticApplicationContext applicationContext = new StaticApplicationContext(); applicationContext.registerSingleton("incomingMessageHandler", IncomingMessageHandler.class); HandlerMethodReturnValueHandler handlerMethodReturnValueHandler = mock( HandlerMethodReturnValueHandler.class); when(handlerMethodReturnValueHandler .supportsReturnType(any(MethodParameter.class))).thenReturn(true); MutablePropertyValues properties = new MutablePropertyValues( Collections.singletonList(new PropertyValue("customReturnValueHandlers", handlerMethodReturnValueHandler))); applicationContext.registerSingleton("queueMessageHandler", QueueMessageHandler.class, properties); applicationContext.refresh(); QueueMessageHandler queueMessageHandler = applicationContext .getBean(QueueMessageHandler.class); // Act queueMessageHandler.handleMessage(MessageBuilder .withPayload("Hello from a sender") .setHeader(QueueMessageHandler.LOGICAL_RESOURCE_ID, "receiveAndReply") .build()); // Assert verify(handlerMethodReturnValueHandler, times(1)).handleReturnValue( any(Object.class), any(MethodParameter.class), any(Message.class)); }
Example #13
Source File: SqsConfigurationTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void configuration_withMinimalBeans_shouldStartSqsListenerContainer() throws Exception { // Arrange & Act AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( MinimalConfiguration.class); SimpleMessageListenerContainer container = applicationContext .getBean(SimpleMessageListenerContainer.class); // Assert assertThat(container.isRunning()).isTrue(); QueueMessageHandler queueMessageHandler = applicationContext .getBean(QueueMessageHandler.class); assertThat(QueueMessageHandler.class.isInstance(queueMessageHandler)).isTrue(); HandlerMethodReturnValueHandler sendToReturnValueHandler = queueMessageHandler .getCustomReturnValueHandlers().get(0); QueueMessagingTemplate messagingTemplate = (QueueMessagingTemplate) ReflectionTestUtils .getField(sendToReturnValueHandler, "messageTemplate"); AmazonSQSBufferedAsyncClient amazonBufferedSqsClient = (AmazonSQSBufferedAsyncClient) ReflectionTestUtils .getField(messagingTemplate, "amazonSqs"); AmazonSQSAsyncClient amazonSqsClient = (AmazonSQSAsyncClient) ReflectionTestUtils .getField(amazonBufferedSqsClient, "realSQS"); assertThat( ReflectionTestUtils.getField(amazonSqsClient, "awsCredentialsProvider")) .isNotNull(); }
Example #14
Source File: MessageBrokerConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void customArgumentAndReturnValueTypes() { ApplicationContext context = loadConfig(CustomConfig.class); SimpAnnotationMethodMessageHandler handler = context.getBean(SimpAnnotationMethodMessageHandler.class); List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers(); assertEquals(1, customResolvers.size()); assertTrue(handler.getArgumentResolvers().contains(customResolvers.get(0))); List<HandlerMethodReturnValueHandler> customHandlers = handler.getCustomReturnValueHandlers(); assertEquals(1, customHandlers.size()); assertTrue(handler.getReturnValueHandlers().contains(customHandlers.get(0))); }
Example #15
Source File: SimpAnnotationMethodMessageHandler.java From spring-analysis-note with MIT License | 5 votes |
@Override protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() { List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>(); // Single-purpose return value types handlers.add(new ListenableFutureReturnValueHandler()); handlers.add(new CompletableFutureReturnValueHandler()); handlers.add(new ReactiveReturnValueHandler()); // Annotation-based return value types SendToMethodReturnValueHandler sendToHandler = new SendToMethodReturnValueHandler(this.brokerTemplate, true); sendToHandler.setHeaderInitializer(this.headerInitializer); handlers.add(sendToHandler); SubscriptionMethodReturnValueHandler subscriptionHandler = new SubscriptionMethodReturnValueHandler(this.clientMessagingTemplate); subscriptionHandler.setHeaderInitializer(this.headerInitializer); handlers.add(subscriptionHandler); // Custom return value types handlers.addAll(getCustomReturnValueHandlers()); // Catch-all sendToHandler = new SendToMethodReturnValueHandler(this.brokerTemplate, false); sendToHandler.setHeaderInitializer(this.headerInitializer); handlers.add(sendToHandler); return handlers; }
Example #16
Source File: QueueMessageHandlerFactory.java From spring-cloud-aws with Apache License 2.0 | 4 votes |
public void setReturnValueHandlers( List<HandlerMethodReturnValueHandler> returnValueHandlers) { this.returnValueHandlers = returnValueHandlers; }
Example #17
Source File: QueueMessageHandler.java From spring-cloud-aws with Apache License 2.0 | 4 votes |
@Override protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() { return new ArrayList<>(this.getCustomReturnValueHandlers()); }
Example #18
Source File: WebSocketConfig.java From consensusj with Apache License 2.0 | 4 votes |
@Override public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { // TODO: ?? }
Example #19
Source File: AbstractWebSocketMessageBrokerConfigurer.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { }
Example #20
Source File: DelegatingWebSocketMessageBrokerConfiguration.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { for (WebSocketMessageBrokerConfigurer configurer : this.configurers) { configurer.addReturnValueHandlers(returnValueHandlers); } }
Example #21
Source File: RqueueMessageHandler.java From rqueue with Apache License 2.0 | 4 votes |
@Override protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() { return new ArrayList<>(getCustomReturnValueHandlers()); }
Example #22
Source File: MessageBrokerConfigurationTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { returnValueHandlers.add(mock(HandlerMethodReturnValueHandler.class)); }
Example #23
Source File: WebSocketMessageBrokerConfig.java From tutorials with MIT License | 4 votes |
@Override public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { // TODO Auto-generated method stub }
Example #24
Source File: AbstractMessageBrokerConfiguration.java From spring4-understanding with Apache License 2.0 | 4 votes |
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { }
Example #25
Source File: AbstractWebSocketMessageBrokerConfigurer.java From java-technology-stack with MIT License | 4 votes |
@Override public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { }
Example #26
Source File: DelegatingWebSocketMessageBrokerConfiguration.java From java-technology-stack with MIT License | 4 votes |
@Override protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { for (WebSocketMessageBrokerConfigurer configurer : this.configurers) { configurer.addReturnValueHandlers(returnValueHandlers); } }
Example #27
Source File: MessageBrokerConfigurationTests.java From java-technology-stack with MIT License | 4 votes |
@Override protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { returnValueHandlers.add(mock(HandlerMethodReturnValueHandler.class)); }
Example #28
Source File: AbstractMessageBrokerConfiguration.java From java-technology-stack with MIT License | 4 votes |
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { }
Example #29
Source File: AbstractWebSocketMessageBrokerConfigurer.java From spring-analysis-note with MIT License | 4 votes |
@Override public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { }
Example #30
Source File: DelegatingWebSocketMessageBrokerConfiguration.java From spring-analysis-note with MIT License | 4 votes |
@Override protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { for (WebSocketMessageBrokerConfigurer configurer : this.configurers) { configurer.addReturnValueHandlers(returnValueHandlers); } }