• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HandlerMethodReturnValueHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler的典型用法代码示例。如果您正苦于以下问题:Java HandlerMethodReturnValueHandler类的具体用法?Java HandlerMethodReturnValueHandler怎么用?Java HandlerMethodReturnValueHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HandlerMethodReturnValueHandler类属于org.springframework.messaging.handler.invocation包,在下文中一共展示了HandlerMethodReturnValueHandler类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: simpAnnotationMethodMessageHandler

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:AbstractMessageBrokerConfiguration.java


示例2: customArgumentAndReturnValueTypes

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@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)));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:MessageBrokerBeanDefinitionParserTests.java


示例3: receiveMessage_withCustomReturnValueHandlers_shouldCallThemBeforeTheDefaultOnes

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Test
public 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));

}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:24,代码来源:QueueMessageHandlerTest.java


示例4: configuration_withMinimalBeans_shouldStartSqsListenerContainer

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Test
public void configuration_withMinimalBeans_shouldStartSqsListenerContainer() throws Exception {
    // Arrange & Act
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MinimalConfiguration.class);
    SimpleMessageListenerContainer container = applicationContext.getBean(SimpleMessageListenerContainer.class);

    // Assert
    assertTrue(container.isRunning());
    QueueMessageHandler queueMessageHandler = applicationContext.getBean(QueueMessageHandler.class);
    assertTrue(QueueMessageHandler.class.isInstance(queueMessageHandler));

    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");
    assertNotNull(ReflectionTestUtils.getField(amazonSqsClient, "awsCredentialsProvider"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:18,代码来源:SqsConfigurationTest.java


示例5: initReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:32,代码来源:SimpAnnotationMethodMessageHandler.java


示例6: customArgumentAndReturnValueTypes

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@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)));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:MessageBrokerConfigurationTests.java


示例7: getQueueMessageHandlerBeanDefinition

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
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();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:8,代码来源:QueueMessageHandlerTest.java


示例8: parseInternal_minimalConfiguration_shouldProduceContainerWithDefaultAmazonSqsBean

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Test
public void parseInternal_minimalConfiguration_shouldProduceContainerWithDefaultAmazonSqsBean() throws Exception {
    //Act
    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-minimal.xml", getClass());

    //Assert
    AmazonSQSAsync amazonSqsClient = applicationContext.getBean(AmazonSQSAsync.class);
    assertNotNull(amazonSqsClient);

    SimpleMessageListenerContainer container = applicationContext.getBean(SimpleMessageListenerContainer.class);
    assertNotNull(container);

    assertSame(amazonSqsClient, ReflectionTestUtils.getField(container, "amazonSqs"));
    assertSame(applicationContext.getBean(StackResourceRegistryDetectingResourceIdResolver.class), ReflectionTestUtils.getField(container, "resourceIdResolver"));

    QueueMessageHandler queueMessageHandler = (QueueMessageHandler) ReflectionTestUtils.getField(container, "messageHandler");
    HandlerMethodReturnValueHandler sendToReturnValueHandler = queueMessageHandler.getReturnValueHandlers().get(0);
    assertTrue(SendToHandlerMethodReturnValueHandler.class.isInstance(sendToReturnValueHandler));
    QueueMessagingTemplate queueMessagingTemplate = (QueueMessagingTemplate) ReflectionTestUtils.getField(sendToReturnValueHandler, "messageTemplate");

    assertTrue(CompositeMessageConverter.class.isInstance(queueMessagingTemplate.getMessageConverter()));

    @SuppressWarnings("unchecked")
    List<MessageConverter> messageConverters = (List<MessageConverter>) ReflectionTestUtils.getField(queueMessagingTemplate.getMessageConverter(), "converters");
    assertEquals(2, messageConverters.size());
    assertTrue(StringMessageConverter.class.isInstance(messageConverters.get(0)));
    assertTrue(MappingJackson2MessageConverter.class.isInstance(messageConverters.get(1)));

    StringMessageConverter stringMessageConverter = (StringMessageConverter) messageConverters.get(0);
    assertSame(String.class, stringMessageConverter.getSerializedPayloadClass());
    assertEquals(false, ReflectionTestUtils.getField(stringMessageConverter, "strictContentTypeMatch"));

    MappingJackson2MessageConverter jackson2MessageConverter = (MappingJackson2MessageConverter) messageConverters.get(1);
    assertSame(String.class, jackson2MessageConverter.getSerializedPayloadClass());
    assertEquals(false, ReflectionTestUtils.getField(jackson2MessageConverter, "strictContentTypeMatch"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:37,代码来源:AnnotationDrivenQueueListenerBeanDefinitionParserTest.java


示例9: addReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Override
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> arg0) {
}
 
开发者ID:weechang,项目名称:Taroco,代码行数:4,代码来源:WebSocketConfiguration.java


示例10: addReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:3,代码来源:AbstractMessageBrokerConfiguration.java


示例11: addReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Override
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
	returnValueHandlers.add(mock(HandlerMethodReturnValueHandler.class));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:MessageBrokerConfigurationTests.java


示例12: addReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Override
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
	for (WebSocketMessageBrokerConfigurer configurer : this.configurers) {
		configurer.addReturnValueHandlers(returnValueHandlers);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:DelegatingWebSocketMessageBrokerConfiguration.java


示例13: addReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Override
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:AbstractWebSocketMessageBrokerConfigurer.java


示例14: addReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Override
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
    // TODO: ??
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:5,代码来源:WebSocketConfig.java


示例15: addReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Override
public void addReturnValueHandlers(final List<HandlerMethodReturnValueHandler> returnValueHandlers) {
}
 
开发者ID:TeeFun,项目名称:TeeFun,代码行数:4,代码来源:WebSocketConfig.java


示例16: initReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
@Override
protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() {

    return new ArrayList<>(this.getCustomReturnValueHandlers());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:6,代码来源:QueueMessageHandler.java


示例17: setReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
public void setReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
    this.returnValueHandlers = returnValueHandlers;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:4,代码来源:QueueMessageHandlerFactory.java


示例18: addReturnValueHandlers

import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler; //导入依赖的package包/类
/**
 * Add handlers to support custom controller method return value types.
 * <p>Using this option does not override the built-in support for handling
 * return values. To customize the built-in support for handling return
 * values, configure  {@code SimpAnnotationMethodMessageHandler} directly.
 * @param returnValueHandlers the handlers to register (initially an empty list)
 * @since 4.1.1
 */
void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers);
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:WebSocketMessageBrokerConfigurer.java



注:本文中的org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RepositoryService类代码示例发布时间:2022-05-22
下一篇:
Java Connection类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap