Fix cloud profile so it works on cloud foundry

This commit is contained in:
Dave Syer
2015-06-02 12:06:49 +01:00
parent 6fa01a85bf
commit 9f70a62bc6
3 changed files with 31 additions and 12 deletions

View File

@@ -18,7 +18,8 @@ package org.springframework.bus.runner.config;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.config.java.AbstractCloudConfig;
import org.springframework.cloud.Cloud;
import org.springframework.cloud.CloudFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@@ -38,15 +39,16 @@ import org.springframework.xd.dirt.integration.rabbit.RabbitMessageBus;
"classpath*:/META-INF/spring-xd/analytics/rabbit-analytics.xml" })
@PropertySource("classpath:/META-INF/spring-bus/rabbit-bus.properties")
public class RabbitServiceConfiguration {
@Configuration
@Profile("cloud")
protected static class CloudConfig extends AbstractCloudConfig {
protected static class CloudConfig {
@Bean
ConnectionFactory rabbitConnectionFactory() {
return connectionFactory().rabbitConnectionFactory();
public Cloud cloud() {
return new CloudFactory().getCloud();
}
@Bean
ConnectionFactory redisConnectionFactory(Cloud cloud) {
return cloud.getSingletonServiceConnector(ConnectionFactory.class, null);
}
}
}

View File

@@ -17,7 +17,8 @@
package org.springframework.bus.runner.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.config.java.AbstractCloudConfig;
import org.springframework.cloud.Cloud;
import org.springframework.cloud.CloudFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@@ -41,11 +42,14 @@ public class RedisServiceConfiguration {
@Configuration
@Profile("cloud")
protected static class CloudConfig extends AbstractCloudConfig {
protected static class CloudConfig {
@Bean
RedisConnectionFactory redisConnectionFactory() {
return connectionFactory().redisConnectionFactory();
public Cloud cloud() {
return new CloudFactory().getCloud();
}
@Bean
RedisConnectionFactory redisConnectionFactory(Cloud cloud) {
return cloud.getSingletonServiceConnector(RedisConnectionFactory.class, null);
}
}

View File

@@ -21,4 +21,17 @@
<module>tap</module>
<module>source-xml</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>