当前位置: 首页>>代码示例>>Java>>正文


Java DirectChannel.getChannelInterceptors方法代码示例

本文整理汇总了Java中org.springframework.integration.channel.DirectChannel.getChannelInterceptors方法的典型用法代码示例。如果您正苦于以下问题:Java DirectChannel.getChannelInterceptors方法的具体用法?Java DirectChannel.getChannelInterceptors怎么用?Java DirectChannel.getChannelInterceptors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.integration.channel.DirectChannel的用法示例。


在下文中一共展示了DirectChannel.getChannelInterceptors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCustomPartitionedProducer

import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testCustomPartitionedProducer() {
	ApplicationContext context = SpringApplication.run(CustomPartitionedProducerTest.TestSource.class, 
			"--spring.jmx.enabled=false",
			"--spring.main.web-application-type=none",
			"--spring.cloud.stream.bindings.output.producer.partitionKeyExtractorClass=org.springframework.cloud.stream.partitioning.CustomPartitionKeyExtractorClass",
			"--spring.cloud.stream.bindings.output.producer.partitionSelectorClass=org.springframework.cloud.stream.partitioning.CustomPartitionSelectorClass");
	Source testSource = context.getBean(Source.class);
	DirectChannel messageChannel = (DirectChannel) testSource.output();
	for (ChannelInterceptor channelInterceptor : messageChannel.getChannelInterceptors()) {
		if (channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor) {
			Field partitionHandlerField = ReflectionUtils
					.findField(MessageConverterConfigurer.PartitioningInterceptor.class, "partitionHandler");
			ReflectionUtils.makeAccessible(partitionHandlerField);
			PartitionHandler partitionHandler = (PartitionHandler) ReflectionUtils.getField(partitionHandlerField,
					channelInterceptor);
			Field partitonKeyExtractorField = ReflectionUtils.findField(PartitionHandler.class,
					"partitionKeyExtractorStrategy");
			ReflectionUtils.makeAccessible(partitonKeyExtractorField);
			Field partitonSelectorField = ReflectionUtils.findField(PartitionHandler.class,
					"partitionSelectorStrategy");
			ReflectionUtils.makeAccessible(partitonSelectorField);
			Assert.assertTrue(((PartitionKeyExtractorStrategy) ReflectionUtils.getField(partitonKeyExtractorField,
					partitionHandler)).getClass().equals(CustomPartitionKeyExtractorClass.class));
			Assert.assertTrue(
					((PartitionSelectorStrategy) ReflectionUtils.getField(partitonSelectorField, partitionHandler))
							.getClass().equals(CustomPartitionSelectorClass.class));
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:31,代码来源:CustomPartitionedProducerTest.java

示例2: testCustomPartitionedProducerByName

import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testCustomPartitionedProducerByName() {
	ApplicationContext context = SpringApplication.run(CustomPartitionedProducerTest.TestSource.class, 
			"--spring.jmx.enabled=false",
			"--spring.main.web-application-type=none",
			"--spring.cloud.stream.bindings.output.producer.partitionKeyExtractorName=customPartitionKeyExtractor",
			"--spring.cloud.stream.bindings.output.producer.partitionSelectorName=customPartitionSelector");
	Source testSource = context.getBean(Source.class);
	DirectChannel messageChannel = (DirectChannel) testSource.output();
	for (ChannelInterceptor channelInterceptor : messageChannel.getChannelInterceptors()) {
		if (channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor) {
			Field partitionHandlerField = ReflectionUtils
					.findField(MessageConverterConfigurer.PartitioningInterceptor.class, "partitionHandler");
			ReflectionUtils.makeAccessible(partitionHandlerField);
			PartitionHandler partitionHandler = (PartitionHandler) ReflectionUtils.getField(partitionHandlerField,
					channelInterceptor);
			Field partitonKeyExtractorField = ReflectionUtils.findField(PartitionHandler.class,
					"partitionKeyExtractorStrategy");
			ReflectionUtils.makeAccessible(partitonKeyExtractorField);
			Field partitonSelectorField = ReflectionUtils.findField(PartitionHandler.class,
					"partitionSelectorStrategy");
			ReflectionUtils.makeAccessible(partitonSelectorField);
			Assert.assertTrue(((PartitionKeyExtractorStrategy) ReflectionUtils.getField(partitonKeyExtractorField,
					partitionHandler)).getClass().equals(CustomPartitionKeyExtractorClass.class));
			Assert.assertTrue(
					((PartitionSelectorStrategy) ReflectionUtils.getField(partitonSelectorField, partitionHandler))
							.getClass().equals(CustomPartitionSelectorClass.class));
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:31,代码来源:CustomPartitionedProducerTest.java

示例3: testCustomPartitionedProducerAsSingletons

import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testCustomPartitionedProducerAsSingletons() {
	ApplicationContext context = SpringApplication.run(CustomPartitionedProducerTest.TestSource.class, 
			"--spring.jmx.enabled=false", "--spring.main.web-application-type=none");
	Source testSource = context.getBean(Source.class);
	DirectChannel messageChannel = (DirectChannel) testSource.output();
	for (ChannelInterceptor channelInterceptor : messageChannel.getChannelInterceptors()) {
		if (channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor) {
			Field partitionHandlerField = ReflectionUtils
					.findField(MessageConverterConfigurer.PartitioningInterceptor.class, "partitionHandler");
			ReflectionUtils.makeAccessible(partitionHandlerField);
			PartitionHandler partitionHandler = (PartitionHandler) ReflectionUtils.getField(partitionHandlerField,
					channelInterceptor);
			Field partitonKeyExtractorField = ReflectionUtils.findField(PartitionHandler.class,
					"partitionKeyExtractorStrategy");
			ReflectionUtils.makeAccessible(partitonKeyExtractorField);
			Field partitonSelectorField = ReflectionUtils.findField(PartitionHandler.class,
					"partitionSelectorStrategy");
			ReflectionUtils.makeAccessible(partitonSelectorField);
			Assert.assertTrue(((PartitionKeyExtractorStrategy) ReflectionUtils.getField(partitonKeyExtractorField,
					partitionHandler)).getClass().equals(CustomPartitionKeyExtractorClass.class));
			Assert.assertTrue(
					((PartitionSelectorStrategy) ReflectionUtils.getField(partitonSelectorField, partitionHandler))
							.getClass().equals(CustomPartitionSelectorClass.class));
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:28,代码来源:CustomPartitionedProducerTest.java

示例4: testCustomPartitionedProducerMultipleInstances

import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
public void testCustomPartitionedProducerMultipleInstances() {
	ApplicationContext context = SpringApplication.run(CustomPartitionedProducerTest.TestSourceMultipleStrategies.class, 
			"--spring.jmx.enabled=false", 
			"--spring.main.web-application-type=none",
			"--spring.cloud.stream.bindings.output.producer.partitionKeyExtractorName=customPartitionKeyExtractorOne",
			"--spring.cloud.stream.bindings.output.producer.partitionSelectorName=customPartitionSelectorTwo");
	Source testSource = context.getBean(Source.class);
	DirectChannel messageChannel = (DirectChannel) testSource.output();
	for (ChannelInterceptor channelInterceptor : messageChannel.getChannelInterceptors()) {
		if (channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor) {
			Field partitionHandlerField = ReflectionUtils
					.findField(MessageConverterConfigurer.PartitioningInterceptor.class, "partitionHandler");
			ReflectionUtils.makeAccessible(partitionHandlerField);
			PartitionHandler partitionHandler = (PartitionHandler) ReflectionUtils.getField(partitionHandlerField,
					channelInterceptor);
			Field partitonKeyExtractorField = ReflectionUtils.findField(PartitionHandler.class,
					"partitionKeyExtractorStrategy");
			ReflectionUtils.makeAccessible(partitonKeyExtractorField);
			Field partitonSelectorField = ReflectionUtils.findField(PartitionHandler.class,
					"partitionSelectorStrategy");
			ReflectionUtils.makeAccessible(partitonSelectorField);
			Assert.assertTrue(((PartitionKeyExtractorStrategy) ReflectionUtils.getField(partitonKeyExtractorField,
					partitionHandler)).getClass().equals(CustomPartitionKeyExtractorClass.class));
			Assert.assertTrue(
					((PartitionSelectorStrategy) ReflectionUtils.getField(partitonSelectorField, partitionHandler))
							.getClass().equals(CustomPartitionSelectorClass.class));
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:30,代码来源:CustomPartitionedProducerTest.java


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