Use application.name in default binding name

Enable autoconfiguration so property placeholders are handled
This commit is contained in:
Marius Bogoevici
2015-08-20 17:27:41 -04:00
committed by Mark Fisher
parent 56469353b3
commit 08f898cb22
2 changed files with 10 additions and 1 deletions

View File

@@ -20,7 +20,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -35,6 +37,9 @@ public class ChannelBindingProperties {
public static final String PATH = "path";
@Value("${spring.application.name:}")
private String springApplicationName;
private Properties consumerProperties = new Properties();
private Properties producerProperties = new Properties();
@@ -81,7 +86,8 @@ public class ChannelBindingProperties {
}
}
// the default path of the binding is the channel name itself
return channelName;
return (StringUtils.hasText(springApplicationName)? springApplicationName + "." : "")
+ channelName;
}
public String getTapChannelName(String channelName) {

View File

@@ -28,6 +28,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.stream.adapter.ChannelBinding;
import org.springframework.cloud.stream.adapter.ChannelBindingAdapter;
@@ -35,6 +36,7 @@ import org.springframework.cloud.stream.adapter.OutputChannelBinding;
import org.springframework.cloud.stream.binder.local.LocalMessageChannelBinder;
import org.springframework.cloud.stream.config.ChannelBindingAdapterConfigurationTests.Empty;
import org.springframework.cloud.stream.utils.MessageChannelBeanDefinitionRegistryUtils;
import org.springframework.cloud.stream.utils.MockBinderConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@@ -133,6 +135,7 @@ public class ChannelBindingAdapterConfigurationTests {
@Configuration
@Import({ChannelBindingAdapterConfiguration.class})
@EnableAutoConfiguration
protected static class Empty {
@Bean
public LocalMessageChannelBinder binder() {