Skip to content

Commit 3105663

Browse files
committed
Merge remote-tracking branch 'upstream/master' into spring-projectsgh-304-add-discovery-clients-order-support.
Add changes after code review. Modify # Conflicts: # spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClient.java # spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryProperties.java
2 parents eb08c8c + 1d64629 commit 3105663

File tree

99 files changed

+1501
-450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1501
-450
lines changed

README.adoc

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
image::https://circleci.com/gh/spring-cloud/spring-cloud-commons.svg?style=svg[Build Status, link=https://circleci.com/gh/spring-cloud/spring-cloud-commons]
44

55

6-
http://pivotal.io/platform-as-a-service/migrating-to-cloud-native-application-architectures-ebook[Cloud Native] is a style of application development that encourages easy adoption of best practices in the areas of continuous delivery and value-driven development. A related discipline is that of building http://12factor.net/[12-factor Apps] in which development practices are aligned with delivery and operations goals, for instance by using declarative programming and management and monitoring. Spring Cloud facilitates these styles of development in a number of specific ways and the starting point is a set of features that all components in a distributed system either need or need easy access to when required.
6+
http://pivotal.io/platform-as-a-service/migrating-to-cloud-native-application-architectures-ebook[Cloud Native] is a style of application development that encourages easy adoption of best practices in the areas of continuous delivery and value-driven development.
7+
A related discipline is that of building http://12factor.net/[12-factor Applications], in which development practices are aligned with delivery and operations goals -- for instance, by using declarative programming and management and monitoring.
8+
Spring Cloud facilitates these styles of development in a number of specific ways.
9+
The starting point is a set of features to which all components in a distributed system need easy access.
710

8-
Many of those features are covered by http://projects.spring.io/spring-boot[Spring Boot], which we build on in Spring Cloud. Some more are delivered by Spring Cloud as two libraries: Spring Cloud Context and Spring Cloud Commons. Spring Cloud Context provides utilities and special services for the `ApplicationContext` of a Spring Cloud application (bootstrap context, encryption, refresh scope and environment endpoints). Spring Cloud Commons is a set of abstractions and common classes used in different Spring Cloud implementations (eg. Spring Cloud Netflix vs. Spring Cloud Consul).
11+
Many of those features are covered by http://projects.spring.io/spring-boot[Spring Boot], on which Spring Cloud builds. Some more features are delivered by Spring Cloud as two libraries: Spring Cloud Context and Spring Cloud Commons.
12+
Spring Cloud Context provides utilities and special services for the `ApplicationContext` of a Spring Cloud application (bootstrap context, encryption, refresh scope, and environment endpoints). Spring Cloud Commons is a set of abstractions and common classes used in different Spring Cloud implementations (such as Spring Cloud Netflix and Spring Cloud Consul).
913

10-
If you are getting an exception due to "Illegal key size" and you are using Sun's JDK, you need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. See the following links for more information:
14+
If you get an exception due to "Illegal key size" and you use Sun's JDK, you need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.
15+
See the following links for more information:
1116

1217
* http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html[Java 6 JCE]
1318
* http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html[Java 7 JCE]
1419
* http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html[Java 8 JCE]
1520
16-
Extract files into JDK/jre/lib/security folder (whichever version of JRE/JDK x64/x86 you are using).
21+
Extract the files into the JDK/jre/lib/security folder for whichever version of JRE/JDK x64/x86 you use.
1722

1823
== Building
1924

docs/pom.xml

+43-41
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,64 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
35
<modelVersion>4.0.0</modelVersion>
46
<groupId>org.springframework.cloud</groupId>
57
<artifactId>spring-cloud-commons-docs</artifactId>
68
<parent>
79
<groupId>org.springframework.cloud</groupId>
810
<artifactId>spring-cloud-commons-parent</artifactId>
9-
<version>2.0.0.BUILD-SNAPSHOT</version>
11+
<version>2.1.0.BUILD-SNAPSHOT</version>
1012
</parent>
1113
<packaging>pom</packaging>
1214
<name>Spring Cloud Commons Docs</name>
1315
<description>Spring Cloud Commons Docs</description>
1416
<properties>
15-
<docs.main>spring-cloud-commons</docs.main>
17+
<docs.main>spring-cloud-commons</docs.main>
1618
<main.basedir>${basedir}/..</main.basedir>
17-
<docs.whitelisted.branches>1.1.x,1.2.x,1.3.x</docs.whitelisted.branches>
19+
<docs.whitelisted.branches>1.2.x,1.3.x,2.0.x</docs.whitelisted.branches>
1820
</properties>
19-
<build>
21+
<build>
2022
<plugins>
21-
<plugin>
22-
<!--skip deploy (this is just a test module) -->
23-
<artifactId>maven-deploy-plugin</artifactId>
24-
<configuration>
25-
<skip>true</skip>
26-
</configuration>
27-
</plugin>
23+
<plugin>
24+
<!--skip deploy (this is just a test module) -->
25+
<artifactId>maven-deploy-plugin</artifactId>
26+
<configuration>
27+
<skip>true</skip>
28+
</configuration>
29+
</plugin>
2830
</plugins>
2931
</build>
30-
<profiles>
32+
<profiles>
3133
<profile>
3234
<id>docs</id>
33-
<build>
34-
<plugins>
35-
<plugin>
36-
<groupId>org.apache.maven.plugins</groupId>
37-
<artifactId>maven-dependency-plugin</artifactId>
38-
</plugin>
39-
<plugin>
40-
<groupId>org.asciidoctor</groupId>
41-
<artifactId>asciidoctor-maven-plugin</artifactId>
42-
<inherited>false</inherited>
43-
</plugin>
44-
<plugin>
45-
<groupId>com.agilejava.docbkx</groupId>
46-
<artifactId>docbkx-maven-plugin</artifactId>
47-
</plugin>
48-
<plugin>
49-
<groupId>org.apache.maven.plugins</groupId>
50-
<artifactId>maven-antrun-plugin</artifactId>
51-
<inherited>false</inherited>
52-
</plugin>
53-
<plugin>
54-
<groupId>org.codehaus.mojo</groupId>
55-
<artifactId>build-helper-maven-plugin</artifactId>
56-
<inherited>false</inherited>
57-
</plugin>
58-
</plugins>
59-
</build>
35+
<build>
36+
<plugins>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-dependency-plugin</artifactId>
40+
</plugin>
41+
<plugin>
42+
<groupId>org.asciidoctor</groupId>
43+
<artifactId>asciidoctor-maven-plugin</artifactId>
44+
<inherited>false</inherited>
45+
</plugin>
46+
<plugin>
47+
<groupId>com.agilejava.docbkx</groupId>
48+
<artifactId>docbkx-maven-plugin</artifactId>
49+
</plugin>
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-antrun-plugin</artifactId>
53+
<inherited>false</inherited>
54+
</plugin>
55+
<plugin>
56+
<groupId>org.codehaus.mojo</groupId>
57+
<artifactId>build-helper-maven-plugin</artifactId>
58+
<inherited>false</inherited>
59+
</plugin>
60+
</plugins>
61+
</build>
6062
</profile>
61-
</profiles>
63+
</profiles>
6264
</project>

docs/src/main/asciidoc/spring-cloud-commons.adoc

+31-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Spring Cloud builds on top of that and adds a few features that probably all com
2424
A Spring Cloud application operates by creating a "`bootstrap`" context, which is a parent context for the main application.
2525
It is responsible for loading configuration properties from the external sources and for decrypting properties in the local external configuration files.
2626
The two contexts share an `Environment`, which is the source of external properties for any Spring application.
27-
By default, bootstrap properties are added with high precedence, so they cannot be overridden by local configuration.
27+
By default, bootstrap properties (not `bootstrap.properties` but properties that are loaded during the bootstrap phase) are added with high precedence, so they cannot be overridden by local configuration.
2828

2929
The bootstrap context uses a different convention for locating external configuration than the main application context.
3030
Instead of `application.yml` (or `.properties`), you can use `bootstrap.yml`, keeping the external configuration for bootstrap and main context
@@ -87,12 +87,12 @@ context you are building), properties in that profile get loaded as well, the sa
8787
=== Overriding the Values of Remote Properties
8888

8989
The property sources that are added to your application by the bootstrap context are often "`remote`" (from example, from Spring Cloud Config Server).
90-
By default, they cannot be overridden locally, except on the command line.
90+
By default, they cannot be overridden locally.
9191
If you want to let your applications override the remote properties with their own System properties or config files, the remote property source has to grant it permission by setting `spring.cloud.config.allowOverride=true` (it does not work to set this locally).
9292
Once that flag is set, two finer-grained settings control the location of the remote properties in relation to system properties and the application's local configuration:
9393

9494
* `spring.cloud.config.overrideNone=true`: Override from any local property source.
95-
* `spring.cloud.config.overrideSystemProperties=false`: Only system properties and environment variables (but not the local config files) should override the remote settings.
95+
* `spring.cloud.config.overrideSystemProperties=false`: Only system properties, command line arguments, and environment variables (but not the local config files) should override the remote settings.
9696

9797
=== Customizing the Bootstrap Configuration
9898

@@ -140,6 +140,15 @@ If you create a jar with this class in it and then add a `META-INF/spring.factor
140140
org.springframework.cloud.bootstrap.BootstrapConfiguration=sample.custom.CustomPropertySourceLocator
141141
----
142142

143+
=== Logging Configuration
144+
145+
If you are going to use Spring Boot to configure log settings than
146+
you should place this configuration in `bootstrap.[yml | properties]
147+
if you would like it to apply to all events.
148+
149+
NOTE: For Spring Cloud to initialize logging configuration properly you cannot use a custom prefix. For example,
150+
using `custom.loggin.logpath` will not be recognized by Spring Cloud when initializing the logging system.
151+
143152
=== Environment Changes
144153

145154
The application listens for an `EnvironmentChangeEvent` and reacts to the change in a couple of standard ways (additional `ApplicationListeners` can be added as `@Beans` by the user in the normal way).
@@ -160,13 +169,20 @@ For instance, a `DataSource` can have its `maxPoolSize` changed at runtime (the
160169
Re-binding `@ConfigurationProperties` does not cover another large class of use cases, where you need more control over the refresh and where you need a change to be atomic over the whole `ApplicationContext`.
161170
To address those concerns, we have `@RefreshScope`.
162171

172+
[[refresh-scope]]
163173
=== Refresh Scope
164174

165175
When there is a configuration change, a Spring `@Bean` that is marked as `@RefreshScope` gets special treatment.
166176
This feature addresses the problem of stateful beans that only get their configuration injected when they are initialized.
167177
For instance, if a `DataSource` has open connections when the database URL is changed via the `Environment`, you probably want the holders of those connections to be able to complete what they are doing.
168178
Then, the next time something borrows a connection from the pool, it gets one with the new URL.
169179

180+
Sometimes, it might even be mandatory to apply the `@RefreshScope`
181+
annotation on some beans which can be only initialized once. If a bean
182+
is "immutable", you will have to either annotate the bean with `@RefreshScope`
183+
or specify the classname under the property key
184+
`spring.cloud.refresh.extra-refreshable`.
185+
170186
Refresh scope beans are lazy proxies that initialize when they are used (that is, when a method is called), and the scope acts as a cache of initialized values.
171187
To force a bean to re-initialize on the next method call, you must invalidate its cache entry.
172188

@@ -208,6 +224,9 @@ For a Spring Boot Actuator application, some additional management endpoints are
208224
* `/actuator/restart` to close the `ApplicationContext` and restart it (disabled by default).
209225
* `/actuator/pause` and `/actuator/resume` for calling the `Lifecycle` methods (`stop()` and `start()` on the `ApplicationContext`).
210226

227+
NOTE: If you disable the `/actuator/restart` endpoint then the `/actuator/pause` and `/actuator/resume` endpoints
228+
will also be disabled since they are just a special case of `/actuator/restart`.
229+
211230
== Spring Cloud Commons: Common Abstractions
212231

213232
Patterns such as service discovery, load balancing, and circuit breakers lend themselves to a common abstraction layer that can be consumed by all Spring Cloud clients, independent of the implementation (for example, discovery with Eureka or Consul).
@@ -287,6 +306,14 @@ public class MyConfiguration {
287306

288307
Each `ServiceRegistry` implementation has its own `Registry` implementation.
289308

309+
* `ZookeeperRegistration` used with `ZookeeperServiceRegistry`
310+
* `EurekaRegistration` used with `EurekaServiceRegistry`
311+
* `ConsulRegistration` used with `ConsulServiceRegistry`
312+
313+
If you are using the `ServiceRegistry` interface, you are going to need to pass the
314+
correct `Registry` implementation for the `ServiceRegistry` implementation you
315+
are using.
316+
290317

291318
==== ServiceRegistry Auto-Registration
292319

@@ -527,7 +554,7 @@ spring:
527554

528555
You can also force the use of only specified network addresses by using a list of regular expressions, as shown in the following example:
529556

530-
.application.yml
557+
.bootstrap.yml
531558
----
532559
spring:
533560
cloud:

0 commit comments

Comments
 (0)