本文整理汇总了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));
}
}
}
示例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));
}
}
}
示例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));
}
}
}
示例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));
}
}
}