From 7489c382ce419358f3a066c3073df91091cb97bf Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 28 Nov 2017 22:32:39 -0500 Subject: [PATCH] General cleanup - Deprecated BindableAdapter in favor of providing default operations in Bindable - Removed 'postProcessBeforeInitialization(..)' from 'BinderAwareRouterBeanPostProcessor' as it is no longer required --- .../cloud/stream/binding/Bindable.java | 20 ++++++++++++------- .../cloud/stream/binding/BindableAdapter.java | 3 +++ .../BinderAwareRouterBeanPostProcessor.java | 7 +------ .../binding/DynamicDestinationsBindable.java | 4 ++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/Bindable.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/Bindable.java index 7a4469586..d3ad5c7c6 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/Bindable.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/Bindable.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.cloud.stream.binding; +import java.util.Collections; import java.util.Set; /** @@ -24,37 +25,42 @@ import java.util.Set; * Intended for internal use. * * @author Marius Bogoevici + * @author Oleg Zhurakousky */ public interface Bindable { /** * Binds all the inputs associated with this instance. */ - void bindInputs(BindingService adapter); + default void bindInputs(BindingService adapter) {} /** * Binds all the outputs associated with this instance. */ - void bindOutputs(BindingService adapter); + default void bindOutputs(BindingService adapter) {} /** * Unbinds all the inputs associated with this instance. */ - void unbindInputs(BindingService adapter); + default void unbindInputs(BindingService adapter) {} /** * Unbinds all the outputs associated with this instance. */ - void unbindOutputs(BindingService adapter); + default void unbindOutputs(BindingService adapter) {} /** * Enumerates all the input binding names. */ - Set getInputs(); + default Set getInputs() { + return Collections.emptySet(); + } /** * Enumerates all the output binding names. */ - Set getOutputs(); + default Set getOutputs() { + return Collections.emptySet(); + } } diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindableAdapter.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindableAdapter.java index 3ed30dc27..310fd2eec 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindableAdapter.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BindableAdapter.java @@ -23,7 +23,10 @@ import java.util.Set; * Default adapter implementation for {@Bindable}. * * @author Ilayaperumal Gopinathan + * + * @deprecated as of version 2.0. Use {@link Bindable} interface instead. */ +@Deprecated public class BindableAdapter implements Bindable { @Override diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BinderAwareRouterBeanPostProcessor.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BinderAwareRouterBeanPostProcessor.java index 10f69018e..4ebfb5f53 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BinderAwareRouterBeanPostProcessor.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/BinderAwareRouterBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,11 +37,6 @@ public class BinderAwareRouterBeanPostProcessor implements BeanPostProcessor { this.channelResolver = channelResolver; } - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - return bean; - } - @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof AbstractMappingMessageRouter) { diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java index a83616a79..0a253bed3 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binding/DynamicDestinationsBindable.java @@ -31,12 +31,12 @@ import org.springframework.cloud.stream.binder.Binding; * * @author Ilayaperumal Gopinathan */ -public final class DynamicDestinationsBindable extends BindableAdapter { +public final class DynamicDestinationsBindable implements Bindable { /** * Map containing dynamic channel names and their bindings. */ - private Map> outputBindings = new HashMap<>(); + private final Map> outputBindings = new HashMap<>(); public void addOutputBinding(String name, Binding binding) { this.outputBindings.put(name, binding);