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

Java ByteArrayMessageConverter类代码示例

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

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



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

示例1: SimpAnnotationMethodMessageHandler

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
/**
 * Create an instance of SimpAnnotationMethodMessageHandler with the given
 * message channels and broker messaging template.
 * @param clientInboundChannel the channel for receiving messages from clients (e.g. WebSocket clients)
 * @param clientOutboundChannel the channel for messages to clients (e.g. WebSocket clients)
 * @param brokerTemplate a messaging template to send application messages to the broker
 */
public SimpAnnotationMethodMessageHandler(SubscribableChannel clientInboundChannel,
		MessageChannel clientOutboundChannel, SimpMessageSendingOperations brokerTemplate) {

	Assert.notNull(clientInboundChannel, "clientInboundChannel must not be null");
	Assert.notNull(clientOutboundChannel, "clientOutboundChannel must not be null");
	Assert.notNull(brokerTemplate, "brokerTemplate must not be null");

	this.clientInboundChannel = clientInboundChannel;
	this.clientMessagingTemplate = new SimpMessagingTemplate(clientOutboundChannel);
	this.brokerTemplate = brokerTemplate;

	Collection<MessageConverter> converters = new ArrayList<MessageConverter>();
	converters.add(new StringMessageConverter());
	converters.add(new ByteArrayMessageConverter());
	this.messageConverter = new CompositeMessageConverter(converters);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:SimpAnnotationMethodMessageHandler.java


示例2: configureMessageConvertersCustomAndDefault

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
@Test
public void configureMessageConvertersCustomAndDefault() {
	final MessageConverter testConverter = mock(MessageConverter.class);

	AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {
		@Override
		protected boolean configureMessageConverters(List<MessageConverter> messageConverters) {
			messageConverters.add(testConverter);
			return true;
		}
	};
	CompositeMessageConverter compositeConverter = config.brokerMessageConverter();

	assertThat(compositeConverter.getConverters().size(), Matchers.is(4));
	Iterator<MessageConverter> iterator = compositeConverter.getConverters().iterator();
	assertThat(iterator.next(), Matchers.is(testConverter));
	assertThat(iterator.next(), Matchers.instanceOf(StringMessageConverter.class));
	assertThat(iterator.next(), Matchers.instanceOf(ByteArrayMessageConverter.class));
	assertThat(iterator.next(), Matchers.instanceOf(MappingJackson2MessageConverter.class));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:MessageBrokerConfigurationTests.java


示例3: brokerMessageConverter

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
@Bean
public CompositeMessageConverter brokerMessageConverter() {
	List<MessageConverter> converters = new ArrayList<MessageConverter>();
	boolean registerDefaults = configureMessageConverters(converters);
	if (registerDefaults) {
		converters.add(new StringMessageConverter());
		converters.add(new ByteArrayMessageConverter());
		if (jackson2Present) {
			converters.add(createJacksonConverter());
		}
	}
	return new CompositeMessageConverter(converters);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:AbstractMessageBrokerConfiguration.java


示例4: configureMessageConvertersDefault

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
@Test
public void configureMessageConvertersDefault() {
	AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig();
	CompositeMessageConverter compositeConverter = config.brokerMessageConverter();

	List<MessageConverter> converters = compositeConverter.getConverters();
	assertThat(converters.size(), Matchers.is(3));
	assertThat(converters.get(0), Matchers.instanceOf(StringMessageConverter.class));
	assertThat(converters.get(1), Matchers.instanceOf(ByteArrayMessageConverter.class));
	assertThat(converters.get(2), Matchers.instanceOf(MappingJackson2MessageConverter.class));

	ContentTypeResolver resolver = ((MappingJackson2MessageConverter) converters.get(2)).getContentTypeResolver();
	assertEquals(MimeTypeUtils.APPLICATION_JSON, ((DefaultContentTypeResolver) resolver).getDefaultMimeType());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:MessageBrokerConfigurationTests.java


示例5: customMessageConverterFailure

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
@Test
public void customMessageConverterFailure() throws Exception {
	DefaultMessageHandlerMethodFactory instance = createInstance();
	MessageConverter messageConverter = new ByteArrayMessageConverter();
	instance.setMessageConverter(messageConverter);
	instance.afterPropertiesSet();

	InvocableHandlerMethod invocableHandlerMethod =
			createInvocableHandlerMethod(instance, "simpleString", String.class);

	thrown.expect(MessageConversionException.class);
	invocableHandlerMethod.invoke(MessageBuilder.withPayload(123).build());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:DefaultMessageHandlerMethodFactoryTests.java


示例6: registerMessageConverter

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
private RuntimeBeanReference registerMessageConverter(Element element, ParserContext context, Object source) {
	Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters");
	ManagedList<? super Object> converters = new ManagedList<Object>();
	if (convertersElement != null) {
		converters.setSource(source);
		for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) {
			Object object = context.getDelegate().parsePropertySubElement(beanElement, null);
			converters.add(object);
		}
	}
	if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) {
		converters.setSource(source);
		converters.add(new RootBeanDefinition(StringMessageConverter.class));
		converters.add(new RootBeanDefinition(ByteArrayMessageConverter.class));
		if (jackson2Present) {
			RootBeanDefinition jacksonConverterDef = new RootBeanDefinition(MappingJackson2MessageConverter.class);
			RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class);
			resolverDef.getPropertyValues().add("defaultMimeType", MimeTypeUtils.APPLICATION_JSON);
			jacksonConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef);
			// Use Jackson factory in order to have JSR-310 and Joda-Time modules registered automatically
			GenericBeanDefinition jacksonFactoryDef = new GenericBeanDefinition();
			jacksonFactoryDef.setBeanClass(Jackson2ObjectMapperFactoryBean.class);
			jacksonFactoryDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
			jacksonFactoryDef.setSource(source);
			jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef);
			converters.add(jacksonConverterDef);
		}
	}
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addIndexedArgumentValue(0, converters);
	RootBeanDefinition messageConverterDef = new RootBeanDefinition(CompositeMessageConverter.class, cavs, null);
	return new RuntimeBeanReference(registerBeanDef(messageConverterDef, context, source));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:MessageBrokerBeanDefinitionParser.java


示例7: configureMessageConverters

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
@Override
public boolean configureMessageConverters(List<MessageConverter> messageConverters) {
    messageConverters.add(new StringMessageConverter());
    messageConverters.add(new ByteArrayMessageConverter());

    GsonMessageConverter gsonMessageConverter = new GsonMessageConverter();
    gsonMessageConverter.setGson(Converters.registerDateTime(new GsonBuilder()).create());
    messageConverters.add(gsonMessageConverter);

    return false;
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:12,代码来源:WebSocketConfig.java


示例8: configureMessageConverters

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
@Override
public boolean configureMessageConverters(
		List<MessageConverter> messageConverters) {
	MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
	converter.setObjectMapper(this.objectMapper);
	DefaultContentTypeResolver resolver = new DefaultContentTypeResolver();
	resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
	converter.setContentTypeResolver(resolver);
	messageConverters.add(new StringMessageConverter());
	messageConverters.add(new ByteArrayMessageConverter());
	messageConverters.add(converter);
	return false;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:WebSocketMessagingAutoConfiguration.java


示例9: configureMessageConverters

import org.springframework.messaging.converter.ByteArrayMessageConverter; //导入依赖的package包/类
@Override
public boolean configureMessageConverters(List<MessageConverter> messageConverters) {
    messageConverters.add(new StringMessageConverter());
    messageConverters.add(new ByteArrayMessageConverter());
    return false;
}
 
开发者ID:youhusky,项目名称:Food_Ordering_System,代码行数:7,代码来源:WebSocketConfig.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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