From 72ee2fae5d51161f07d9e0dd5b1b20ff70620e42 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Wed, 19 Sep 2018 11:26:48 +0200 Subject: [PATCH] GH-1485 polishing, cleanup and deprecation removal Resolves #1485 --- .../stream/test/binder/TestSupportBinder.java | 4 ++-- .../binder/AbstractMessageChannelBinder.java | 4 ++-- .../binding/BinderAwareChannelResolver.java | 24 ++++--------------- ...ndersHealthIndicatorAutoConfiguration.java | 5 ++-- .../config/BindingServiceConfiguration.java | 7 ++---- ...ultDestinationPublishingMeterRegistry.java | 4 ++-- 6 files changed, 15 insertions(+), 33 deletions(-) diff --git a/spring-cloud-stream-test-support/src/main/java/org/springframework/cloud/stream/test/binder/TestSupportBinder.java b/spring-cloud-stream-test-support/src/main/java/org/springframework/cloud/stream/test/binder/TestSupportBinder.java index 28dd75426..dec3d626e 100644 --- a/spring-cloud-stream-test-support/src/main/java/org/springframework/cloud/stream/test/binder/TestSupportBinder.java +++ b/spring-cloud-stream-test-support/src/main/java/org/springframework/cloud/stream/test/binder/TestSupportBinder.java @@ -41,7 +41,7 @@ import org.springframework.messaging.MessagingException; import org.springframework.messaging.SubscribableChannel; import org.springframework.messaging.converter.DefaultContentTypeResolver; import org.springframework.messaging.converter.MessageConverter; -import org.springframework.messaging.support.ChannelInterceptorAdapter; +import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.messaging.support.MessageBuilder; import org.springframework.util.Assert; import org.springframework.util.MimeType; @@ -166,7 +166,7 @@ public class TestSupportBinder implements Binder bindingTargetFactory; @@ -57,8 +51,6 @@ public class BinderAwareChannelResolver extends BeanFactoryMessageChannelDestina private ConfigurableListableBeanFactory beanFactory; - private final GlobalChannelInterceptorProcessor globalChannelInterceptorProcessor; - public BinderAwareChannelResolver(BindingService bindingService, AbstractBindingTargetFactory bindingTargetFactory, DynamicDestinationsBindable dynamicDestinationsBindable) { @@ -72,7 +64,11 @@ public class BinderAwareChannelResolver extends BeanFactoryMessageChannelDestina this(bindingService, bindingTargetFactory, dynamicDestinationsBindable, callback, null); } + /** + * @deprecated since GlobalChannelInterceptorProcessor is no longer used + */ @SuppressWarnings("rawtypes") + @Deprecated public BinderAwareChannelResolver(BindingService bindingService, AbstractBindingTargetFactory bindingTargetFactory, DynamicDestinationsBindable dynamicDestinationsBindable, NewDestinationBindingCallback callback, @@ -83,7 +79,6 @@ public class BinderAwareChannelResolver extends BeanFactoryMessageChannelDestina this.bindingService = bindingService; this.bindingTargetFactory = bindingTargetFactory; this.newBindingCallback = callback; - this.globalChannelInterceptorProcessor = globalChannelInterceptorProcessor; } @Override @@ -136,17 +131,6 @@ public class BinderAwareChannelResolver extends BeanFactoryMessageChannelDestina } } - private void instrumentChannelWithGlobalInterceptors(MessageChannel channel, String channelName) { - if (channel instanceof ChannelInterceptorAware) { - if (this.globalChannelInterceptorProcessor != null) { - this.globalChannelInterceptorProcessor.addMatchingInterceptors((ChannelInterceptorAware) channel, channelName); - } - } - else { - logger.warn("Failed to add global interceptors to '" + channelName + "' since it is not an instance of ChannelInterceptorAware."); - } - } - /** * Configure a new destination before it is bound. * @param the extended properties type. If you need to support dynamic binding diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindersHealthIndicatorAutoConfiguration.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindersHealthIndicatorAutoConfiguration.java index 31a7c3998..4ee533dfa 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindersHealthIndicatorAutoConfiguration.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindersHealthIndicatorAutoConfiguration.java @@ -23,6 +23,7 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfi import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; import org.springframework.boot.actuate.health.AbstractHealthIndicator; import org.springframework.boot.actuate.health.CompositeHealthIndicator; +import org.springframework.boot.actuate.health.DefaultHealthIndicatorRegistry; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.OrderedHealthAggregator; @@ -51,7 +52,7 @@ public class BindersHealthIndicatorAutoConfiguration { @Bean @ConditionalOnMissingBean(name = "bindersHealthIndicator") public CompositeHealthIndicator bindersHealthIndicator() { - return new CompositeHealthIndicator(new OrderedHealthAggregator()); + return new CompositeHealthIndicator(new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry()); } @Bean @@ -85,7 +86,7 @@ public class BindersHealthIndicatorAutoConfiguration { // this can happen due to the fact that configuration is inherited HealthIndicator binderHealthIndicator = indicators.isEmpty() ? new DefaultHealthIndicator() : new CompositeHealthIndicator(healthAggregator, indicators); - this.bindersHealthIndicator.addHealthIndicator(binderConfigurationName, binderHealthIndicator); + bindersHealthIndicator.getRegistry().register(binderConfigurationName, binderHealthIndicator); } } diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java index beff86d0f..206199b4a 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceConfiguration.java @@ -53,7 +53,6 @@ import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Role; import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.integration.config.GlobalChannelInterceptorProcessor; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.router.AbstractMappingMessageRouter; import org.springframework.lang.Nullable; @@ -193,11 +192,9 @@ public class BindingServiceConfiguration { public BinderAwareChannelResolver binderAwareChannelResolver(BindingService bindingService, AbstractBindingTargetFactory bindingTargetFactory, DynamicDestinationsBindable dynamicDestinationsBindable, - @Nullable BinderAwareChannelResolver.NewDestinationBindingCallback callback, - @Nullable GlobalChannelInterceptorProcessor globalChannelInterceptorProcessor) { + @Nullable BinderAwareChannelResolver.NewDestinationBindingCallback callback) { - return new BinderAwareChannelResolver(bindingService, bindingTargetFactory, dynamicDestinationsBindable, - callback, globalChannelInterceptorProcessor); + return new BinderAwareChannelResolver(bindingService, bindingTargetFactory, dynamicDestinationsBindable, callback); } @Bean diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/micrometer/DefaultDestinationPublishingMeterRegistry.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/micrometer/DefaultDestinationPublishingMeterRegistry.java index d672cc391..585c828af 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/micrometer/DefaultDestinationPublishingMeterRegistry.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/micrometer/DefaultDestinationPublishingMeterRegistry.java @@ -210,11 +210,11 @@ class DefaultDestinationPublishingMeterRegistry extends MeterRegistry implements } private Metric toSummaryMetric(DistributionSummary summary) { - return new Metric(summary.getId(), summary.takeSnapshot(false)); + return new Metric(summary.getId(), summary.takeSnapshot()); } private Metric toTimerMetric(Timer timer) { - return new Metric(timer.getId(), timer.takeSnapshot(false)); + return new Metric(timer.getId(), timer.takeSnapshot()); } /**