From f2c957fd9311fd48f5c120bee92391a708f38aa3 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Thu, 28 Aug 2014 17:10:38 -0600 Subject: [PATCH] hacky spring cloud connector so we don't have to configure each service individually for the cloud local connector --- pom.xml | 15 ++++++++++ .../notcfconfig/NotCFConfigConnector.java | 28 +++++++++++++++++++ .../org.springframework.cloud.CloudConnector | 1 + ...ork.cloud.notcfconfig.NotCFConfigConnector | 5 ++++ 4 files changed, 49 insertions(+) create mode 100644 src/main/java/org/springframework/cloud/notcfconfig/NotCFConfigConnector.java create mode 100644 src/main/resources/META-INF/services/org.springframework.cloud.CloudConnector create mode 100644 src/main/resources/META-INF/services/org.springframework.cloud.notcfconfig.NotCFConfigConnector diff --git a/pom.xml b/pom.xml index 2788cac..42e435c 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,21 @@ spring-platform-config-client 1.0.0.BUILD-SNAPSHOT + + org.springframework.cloud + spring-cloud-spring-service-connector + 1.1.0.BUILD-SNAPSHOT + + + org.springframework.cloud + spring-cloud-localconfig-connector + 1.1.0.BUILD-SNAPSHOT + + + org.springframework.cloud + spring-cloud-cloudfoundry-connector + 1.1.0.BUILD-SNAPSHOT + org.projectlombok lombok diff --git a/src/main/java/org/springframework/cloud/notcfconfig/NotCFConfigConnector.java b/src/main/java/org/springframework/cloud/notcfconfig/NotCFConfigConnector.java new file mode 100644 index 0000000..bd0ba15 --- /dev/null +++ b/src/main/java/org/springframework/cloud/notcfconfig/NotCFConfigConnector.java @@ -0,0 +1,28 @@ +package org.springframework.cloud.notcfconfig; + +import org.springframework.cloud.localconfig.LocalConfigConnector; +import org.springframework.cloud.service.UriBasedServiceData; +import org.springframework.cloud.util.EnvironmentAccessor; + +import java.util.Collections; +import java.util.List; + +/** + * @author Spencer Gibb + * Let's spring boots current auto-configuration work, effectivly disabling spring cloud local + * TODO: workaround for not having to configure the local cloud connector + */ +public class NotCFConfigConnector extends LocalConfigConnector { + + private EnvironmentAccessor env = new EnvironmentAccessor(); + + @Override + public boolean isInMatchingCloud() { + return env.getEnvValue("VCAP_APPLICATION") == null; + } + + @Override + protected List getServicesData() { + return Collections.emptyList(); + } +} diff --git a/src/main/resources/META-INF/services/org.springframework.cloud.CloudConnector b/src/main/resources/META-INF/services/org.springframework.cloud.CloudConnector new file mode 100644 index 0000000..440a3f3 --- /dev/null +++ b/src/main/resources/META-INF/services/org.springframework.cloud.CloudConnector @@ -0,0 +1 @@ +org.springframework.cloud.notcfconfig.NotCFConfigConnector \ No newline at end of file diff --git a/src/main/resources/META-INF/services/org.springframework.cloud.notcfconfig.NotCFConfigConnector b/src/main/resources/META-INF/services/org.springframework.cloud.notcfconfig.NotCFConfigConnector new file mode 100644 index 0000000..f8a14d4 --- /dev/null +++ b/src/main/resources/META-INF/services/org.springframework.cloud.notcfconfig.NotCFConfigConnector @@ -0,0 +1,5 @@ +org.springframework.cloud.localconfig.AmqpServiceInfoCreator +org.springframework.cloud.localconfig.MongoServiceInfoCreator +org.springframework.cloud.localconfig.MysqlServiceInfoCreator +org.springframework.cloud.localconfig.PostgresqlServiceInfoCreator +org.springframework.cloud.localconfig.RedisServiceInfoCreator \ No newline at end of file