diff --git a/settings.gradle b/settings.gradle index c22faa4..bc6b88f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,5 @@ rootProject.name = "spring-cloud" include "${rootProject.name}-core" include "${rootProject.name}-cloudfoundry-connector" include "${rootProject.name}-spring-service-connector" -include "${rootProject.name}-heroku-connector" \ No newline at end of file +include "${rootProject.name}-heroku-connector" +include "${rootProject.name}-localconfig-connector" diff --git a/spring-cloud-localconfig-connector/.gitignore b/spring-cloud-localconfig-connector/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/spring-cloud-localconfig-connector/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/spring-cloud-localconfig-connector/README.md b/spring-cloud-localconfig-connector/README.md new file mode 100644 index 0000000..f9788aa --- /dev/null +++ b/spring-cloud-localconfig-connector/README.md @@ -0,0 +1,59 @@ +Local-configuration connector for Spring Cloud +======================================= + +Provides the ability to configure Spring Cloud services locally for development or testing. +The current implementation reads from Java properties only; in order to prevent dependencies +on the Spring Framework, the placeholder functionality is unavailable in the connector. +Pull requests for also inspecting environment variables are welcome. + +Property sources +---------------- +This connector first attempts to read the system properties generally and a property named +`spring.cloud.propertiesFile` specifically. If the system properties are not readable +(the security manager denies `checkPropertiesAccess`), then they will be treated as empty. +If a system property named `spring.cloud.propertiesFile` is found, that file will be loaded +as a property list. + +###Programmatically supplying properties +You can programmatically supply a property source by calling the static method +`LocalConfigConnector.supplyProperties(InputStream)` before invoking `getCloud()`. +Calling this method will cause the connector to read the stream as a property list +and then close the stream. Calling this method after invoking `getCloud()` will +still read the stream, but the properties will have no effect on the connector +service configuration. Calling this method multiple times will load the supplied +streams onto the same `Properties` object, overwriting duplicates. + +###Property order +To provide the maximum configuration flexibility, the connector will scan the available +property sources in this order: + +- programmatically-supplied properties +- properties read from `spring.cloud.propertiesFile` +- system properties + +The last definition of a specific service ID wins. The connector will log a message at +`INFO` to notify of service overrides for the same type of service and at `WARN` if you +override a service ID with a URI to a different type of service. + +Activating the connector +------------------------ +The Spring Cloud core expects exactly one cloud connector to return `true` for +`isInMatchingCloud()`. This connector identifies the "local cloud" by the presence of +a property named `spring.cloud.appId`, which will be used in the `ApplicationInstanceInfo`. + +Service definitions +------------------- +If the connector is activated, it will iterate through all the available properties +for keys matching the pattern `spring.cloud.{serviceId}`. Each value is interpreted as a URI +to the services, and the type of service is determined from the scheme. All of the standard +`UriBasedServiceInfo`s are supported. + +Supporting additional services +------------------------------ +Please see the documentation for [cloudfoundry-connector](../spring-cloud-cloudfoundry-connector), since the same +mechanism applies to any cloud connector. + +Instance ID +----------- +This connector will create a UUID for use as the instance ID, as Java does not provide +any portable mechanism for reliably determining hostnames or PIDs. \ No newline at end of file diff --git a/spring-cloud-localconfig-connector/build.gradle b/spring-cloud-localconfig-connector/build.gradle new file mode 100644 index 0000000..eb5f5b6 --- /dev/null +++ b/spring-cloud-localconfig-connector/build.gradle @@ -0,0 +1,5 @@ +description = 'Spring Cloud local-configuration connector' + +dependencies { + compile project(':spring-cloud-core') +}