From a3357048330bea598be3946b543a98ce93f99345 Mon Sep 17 00:00:00 2001 From: Ilayaperumal Gopinathan Date: Wed, 19 Aug 2015 11:21:32 -0700 Subject: [PATCH] Remove ChannelBindingAdapterRunner - Since `ChannelBindingAdapter` implements `SmartLifecycle`, it is expected to start with the highest precedence when the lifecycle beans are started. - Remove `autoStartup` from `ChannelBindingProperties` - This property was used by the CBARunner to start the CBA if autoStartup is true - Since all the lifecycle beans (inbound/outbound channel adapters) are started with appropriate phase and autoStartup flag the ChannelBindingProperties's autoStartup isn't needed. --- .../cloud/stream/annotation/EnableModule.java | 4 +- .../config/ChannelBindingAdapterRunner.java | 41 ------------------- .../config/ChannelBindingProperties.java | 10 ----- 3 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/ChannelBindingAdapterRunner.java diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/annotation/EnableModule.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/annotation/EnableModule.java index ebb55aef0..6433af40b 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/annotation/EnableModule.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/annotation/EnableModule.java @@ -25,7 +25,6 @@ import java.lang.annotation.Target; import org.springframework.cloud.stream.config.AggregateBuilderConfiguration; import org.springframework.cloud.stream.config.ChannelBindingAdapterConfiguration; -import org.springframework.cloud.stream.config.ChannelBindingAdapterRunner; import org.springframework.cloud.stream.config.ModuleRegistrar; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -43,8 +42,7 @@ import org.springframework.context.annotation.Import; @Inherited @Configuration @Import({ - ChannelBindingAdapterConfiguration.class, ChannelBindingAdapterRunner.class, - AggregateBuilderConfiguration.class, ModuleRegistrar.class}) + ChannelBindingAdapterConfiguration.class, AggregateBuilderConfiguration.class, ModuleRegistrar.class}) public @interface EnableModule { Class[] value() default {}; diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/ChannelBindingAdapterRunner.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/ChannelBindingAdapterRunner.java deleted file mode 100644 index 3f25d14e2..000000000 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/ChannelBindingAdapterRunner.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.stream.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.cloud.stream.adapter.ChannelBindingAdapter; - -/** - * @author Dave Syer - * - */ -public class ChannelBindingAdapterRunner implements CommandLineRunner { - - @Autowired - private ChannelBindingProperties module; - - @Autowired - private ChannelBindingAdapter adapter; - - @Override - public void run(String... args) throws Exception { - if (!adapter.isRunning() && module.isAutoStartup()) { - adapter.start(); - } - } -} diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/ChannelBindingProperties.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/ChannelBindingProperties.java index cee840b8c..3d00769e3 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/ChannelBindingProperties.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/ChannelBindingProperties.java @@ -39,8 +39,6 @@ public class ChannelBindingProperties { private Properties producerProperties = new Properties(); - private boolean autoStartup = true; - private Map bindings = new HashMap<>(); public Properties getConsumerProperties() { @@ -59,14 +57,6 @@ public class ChannelBindingProperties { this.producerProperties = producerProperties; } - public boolean isAutoStartup() { - return this.autoStartup; - } - - public void setAutoStartup(boolean autoStartup) { - this.autoStartup = autoStartup; - } - public Map getBindings() { return bindings; }