diff --git a/2.1.x/index.html b/2.1.x/index.html index dbed115e..080d078c 100644 --- a/2.1.x/index.html +++ b/2.1.x/index.html @@ -90,7 +90,7 @@ $(addBlockSwitches);
-

2.1.2.BUILD-SNAPSHOT

+

2.1.3.BUILD-SNAPSHOT

diff --git a/2.1.x/multi/multi__spring_cloud_commons_common_abstractions.html b/2.1.x/multi/multi__spring_cloud_commons_common_abstractions.html index 342904dd..3730cea2 100644 --- a/2.1.x/multi/multi__spring_cloud_commons_common_abstractions.html +++ b/2.1.x/multi/multi__spring_cloud_commons_common_abstractions.html @@ -19,8 +19,8 @@ properties to set the order of the DiscoveryClient implementations provided by Spring Cloud, among others ConsulDiscoveryClient, EurekaDiscoveryClient and ZookeeperDiscoveryClient. In order to do it, you just need to set the spring.cloud.{clientIdentifier}.discovery.order (or eureka.client.order for Eureka) property to the desired value.

2.2 ServiceRegistry

Commons now provides a ServiceRegistry interface that provides methods such as register(Registration) and deregister(Registration), which let you provide custom registered services. -Registration is a marker interface.

The following example shows the ServiceRegistry in use:

@Configuration
-@EnableDiscoveryClient(autoRegister=false)
+Registration is a marker interface.

The following example shows the ServiceRegistry in use:

@Configuration
+@EnableDiscoveryClient(autoRegister=false)
 public class MyConfiguration {
     private ServiceRegistry registry;
 
@@ -48,18 +48,18 @@ Using POST to the same endpoint with a JSON body changes the status of the curre
 The JSON body has to include the status field with the preferred value.
 Please see the documentation of the ServiceRegistry implementation you use for the allowed values when updating the status and the values returned for the status.
 For instance, Eureka’s supported statuses are UP, DOWN, OUT_OF_SERVICE, and UNKNOWN.

2.3 Spring RestTemplate as a Load Balancer Client

RestTemplate can be automatically configured to use ribbon. -To create a load-balanced RestTemplate, create a RestTemplate @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@Configuration
+To create a load-balanced RestTemplate, create a RestTemplate @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@Configuration
 public class MyConfiguration {
 
-    @LoadBalanced
-    @Bean
+    @LoadBalanced
+    @Bean
     RestTemplate restTemplate() {
         return new RestTemplate();
     }
 }
 
 public class MyClass {
-    @Autowired
+    @Autowired
     private RestTemplate restTemplate;
 
     public String doOtherStuff() {
@@ -70,18 +70,18 @@ To create a load-balanced RestTemplate, create a 

The URI needs to use a virtual host name (that is, a service name, not a host name). The Ribbon client is used to create a full physical address. See RibbonAutoConfiguration for details of how the RestTemplate is set up.

2.4 Spring WebClient as a Load Balancer Client

WebClient can be automatically configured to use the LoadBalancerClient. -To create a load-balanced WebClient, create a WebClient.Builder @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@Configuration
+To create a load-balanced WebClient, create a WebClient.Builder @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@Configuration
 public class MyConfiguration {
 
-	@Bean
-	@LoadBalanced
+	@Bean
+	@LoadBalanced
 	public WebClient.Builder loadBalancedWebClientBuilder() {
 		return WebClient.builder();
 	}
 }
 
 public class MyClass {
-    @Autowired
+    @Autowired
     private WebClient.Builder webClientBuilder;
 
     public Mono<String> doOtherStuff() {
@@ -95,12 +95,12 @@ You can enable it by adding RestTemplate honors some of the Ribbon configuration values related to retrying failed requests.
 You can use client.ribbon.MaxAutoRetries, client.ribbon.MaxAutoRetriesNextServer, and client.ribbon.OkToRetryOnAllOperations properties.
 If you would like to disable the retry logic with Spring Retry on the classpath, you can set spring.cloud.loadbalancer.retry.enabled=false.
-See the Ribbon documentation for a description of what these properties do.

If you would like to implement a BackOffPolicy in your retries, you need to create a bean of type LoadBalancedRetryFactory and override the createBackOffPolicy method:

@Configuration
+See the Ribbon documentation for a description of what these properties do.

If you would like to implement a BackOffPolicy in your retries, you need to create a bean of type LoadBalancedRetryFactory and override the createBackOffPolicy method:

@Configuration
 public class MyConfiguration {
-    @Bean
+    @Bean
     LoadBalancedRetryFactory retryFactory() {
         return new LoadBalancedRetryFactory() {
-            @Override
+            @Override
             public BackOffPolicy createBackOffPolicy(String service) {
         		return new ExponentialBackOffPolicy();
         	}
@@ -108,26 +108,26 @@ See the 
[Note]Note

client in the preceding examples should be replaced with your Ribbon client’s name.

If you want to add one or more RetryListener implementations to your retry functionality, you need to create a bean of type LoadBalancedRetryListenerFactory and return the RetryListener array -you would like to use for a given service, as shown in the following example:

@Configuration
+you would like to use for a given service, as shown in the following example:

@Configuration
 public class MyConfiguration {
-    @Bean
+    @Bean
     LoadBalancedRetryListenerFactory retryListenerFactory() {
         return new LoadBalancedRetryListenerFactory() {
-            @Override
+            @Override
             public RetryListener[] createRetryListeners(String service) {
                 return new RetryListener[]{new RetryListener() {
-                    @Override
+                    @Override
                     public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
                         //TODO Do you business...
                         return true;
                     }
 
-                    @Override
+                    @Override
                      public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
                         //TODO Do you business...
                     }
 
-                    @Override
+                    @Override
                     public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
                         //TODO Do you business...
                     }
@@ -136,28 +136,28 @@ you would like to use for a given service, as shown in the following example:

2.5 Multiple RestTemplate objects

If you want a RestTemplate that is not load-balanced, create a RestTemplate bean and inject it. -To access the load-balanced RestTemplate, use the @LoadBalanced qualifier when you create your @Bean, as shown in the following example:\

@Configuration
+To access the load-balanced RestTemplate, use the @LoadBalanced qualifier when you create your @Bean, as shown in the following example:\

@Configuration
 public class MyConfiguration {
 
-    @LoadBalanced
-    @Bean
+    @LoadBalanced
+    @Bean
     RestTemplate loadBalanced() {
         return new RestTemplate();
     }
 
-    @Primary
-    @Bean
+    @Primary
+    @Bean
     RestTemplate restTemplate() {
         return new RestTemplate();
     }
 }
 
 public class MyClass {
-    @Autowired
+    @Autowired
     private RestTemplate restTemplate;
 
-    @Autowired
-    @LoadBalanced
+    @Autowired
+    @LoadBalanced
     private RestTemplate loadBalanced;
 
     public String doOtherStuff() {
@@ -168,7 +168,7 @@ To access the load-balanced RestTemplate, use the <
         return restTemplate.getForObject("https://example.com", String.class);
     }
 }
[Important]Important

Notice the use of the @Primary annotation on the plain RestTemplate declaration in the preceding example to disambiguate the unqualified @Autowired injection.

[Tip]Tip

If you see errors such as java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89, try injecting RestOperations or setting spring.aop.proxyTargetClass=true.

2.6 Spring WebFlux WebClient as a Load Balancer Client

WebClient can be configured to use the LoadBalancerClient. LoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath. The following example shows how to configure a WebClient to use load balancer:

public class MyClass {
-    @Autowired
+    @Autowired
     private LoadBalancerExchangeFilterFunction lbFunction;
 
     public Mono<String> doOtherStuff() {
@@ -210,19 +210,19 @@ You can also disable the creation of these beans by setting 

2.9.1 Feature types

There are two types of 'features': abstract and named.

Abstract features are features where an interface or abstract class is defined and that an implementation the creates, such as DiscoveryClient, LoadBalancerClient, or LockService. The abstract class or interface is used to find a bean of that type in the context. -The version displayed is bean.getClass().getPackage().getImplementationVersion().

Named features are features that do not have a particular class they implement, such as "Circuit Breaker", "API Gateway", "Spring Cloud Bus", and others. These features require a name and a bean type.

2.9.2 Declaring features

Any module can declare any number of HasFeature beans, as shown in the following examples:

@Bean
+The version displayed is bean.getClass().getPackage().getImplementationVersion().

Named features are features that do not have a particular class they implement, such as "Circuit Breaker", "API Gateway", "Spring Cloud Bus", and others. These features require a name and a bean type.

2.9.2 Declaring features

Any module can declare any number of HasFeature beans, as shown in the following examples:

@Bean
 public HasFeatures commonsFeatures() {
   return HasFeatures.abstractFeatures(DiscoveryClient.class, LoadBalancerClient.class);
 }
 
-@Bean
+@Bean
 public HasFeatures consulFeatures() {
   return HasFeatures.namedFeatures(
     new NamedFeature("Spring Cloud Bus", ConsulBusAutoConfiguration.class),
     new NamedFeature("Circuit Breaker", HystrixCommandAspect.class));
 }
 
-@Bean
+@Bean
 HasFeatures localFeatures() {
   return HasFeatures.builder()
       .abstractFeature(Foo.class)
diff --git a/2.1.x/multi/multi__spring_cloud_context_application_context_services.html b/2.1.x/multi/multi__spring_cloud_context_application_context_services.html
index 46644852..9cdd05b3 100644
--- a/2.1.x/multi/multi__spring_cloud_context_application_context_services.html
+++ b/2.1.x/multi/multi__spring_cloud_context_application_context_services.html
@@ -47,10 +47,10 @@ If you want to control the startup sequence, classes can be marked with an @ComponentScan or @SpringBootApplication annotated configuration classes.

The bootstrap process ends by injecting initializers into the main SpringApplication instance (which is the normal Spring Boot startup sequence, whether it is running as a standalone application or deployed in an application server). First, a bootstrap context is created from the classes found in spring.factories. Then, all @Beans of type ApplicationContextInitializer are added to the main SpringApplication before it is started.

1.6 Customizing the Bootstrap Property Sources

The default property source for external configuration added by the bootstrap process is the Spring Cloud Config Server, but you can add additional sources by adding beans of type PropertySourceLocator to the bootstrap context (through spring.factories). -For instance, you can insert additional properties from a different server or from a database.

As an example, consider the following custom locator:

@Configuration
+For instance, you can insert additional properties from a different server or from a database.

As an example, consider the following custom locator:

@Configuration
 public class CustomPropertySourceLocator implements PropertySourceLocator {
 
-    @Override
+    @Override
     public PropertySource<?> locate(Environment environment) {
         return new MapPropertySource("customProperty",
                 Collections.<String, Object>singletonMap("property.from.sample.custom.source", "worked as intended"));
diff --git a/2.1.x/single/spring-cloud-commons.html b/2.1.x/single/spring-cloud-commons.html
index ad6f9476..81305a85 100644
--- a/2.1.x/single/spring-cloud-commons.html
+++ b/2.1.x/single/spring-cloud-commons.html
@@ -53,10 +53,10 @@ If you want to control the startup sequence, classes can be marked with an @ComponentScan or @SpringBootApplication annotated configuration classes.

The bootstrap process ends by injecting initializers into the main SpringApplication instance (which is the normal Spring Boot startup sequence, whether it is running as a standalone application or deployed in an application server). First, a bootstrap context is created from the classes found in spring.factories. Then, all @Beans of type ApplicationContextInitializer are added to the main SpringApplication before it is started.

1.6 Customizing the Bootstrap Property Sources

The default property source for external configuration added by the bootstrap process is the Spring Cloud Config Server, but you can add additional sources by adding beans of type PropertySourceLocator to the bootstrap context (through spring.factories). -For instance, you can insert additional properties from a different server or from a database.

As an example, consider the following custom locator:

@Configuration
+For instance, you can insert additional properties from a different server or from a database.

As an example, consider the following custom locator:

@Configuration
 public class CustomPropertySourceLocator implements PropertySourceLocator {
 
-    @Override
+    @Override
     public PropertySource<?> locate(Environment environment) {
         return new MapPropertySource("customProperty",
                 Collections.<String, Object>singletonMap("property.from.sample.custom.source", "worked as intended"));
@@ -118,8 +118,8 @@ properties to set the order of the DiscoveryClient
 implementations provided by Spring Cloud, among others  ConsulDiscoveryClient, EurekaDiscoveryClient and
 ZookeeperDiscoveryClient. In order to do it, you just need to set the
 spring.cloud.{clientIdentifier}.discovery.order (or eureka.client.order for Eureka) property to the desired value.

2.2 ServiceRegistry

Commons now provides a ServiceRegistry interface that provides methods such as register(Registration) and deregister(Registration), which let you provide custom registered services. -Registration is a marker interface.

The following example shows the ServiceRegistry in use:

@Configuration
-@EnableDiscoveryClient(autoRegister=false)
+Registration is a marker interface.

The following example shows the ServiceRegistry in use:

@Configuration
+@EnableDiscoveryClient(autoRegister=false)
 public class MyConfiguration {
     private ServiceRegistry registry;
 
@@ -147,18 +147,18 @@ Using POST to the same endpoint with a JSON body changes the status of the curre
 The JSON body has to include the status field with the preferred value.
 Please see the documentation of the ServiceRegistry implementation you use for the allowed values when updating the status and the values returned for the status.
 For instance, Eureka’s supported statuses are UP, DOWN, OUT_OF_SERVICE, and UNKNOWN.

2.3 Spring RestTemplate as a Load Balancer Client

RestTemplate can be automatically configured to use ribbon. -To create a load-balanced RestTemplate, create a RestTemplate @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@Configuration
+To create a load-balanced RestTemplate, create a RestTemplate @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@Configuration
 public class MyConfiguration {
 
-    @LoadBalanced
-    @Bean
+    @LoadBalanced
+    @Bean
     RestTemplate restTemplate() {
         return new RestTemplate();
     }
 }
 
 public class MyClass {
-    @Autowired
+    @Autowired
     private RestTemplate restTemplate;
 
     public String doOtherStuff() {
@@ -169,18 +169,18 @@ To create a load-balanced RestTemplate, create a 

The URI needs to use a virtual host name (that is, a service name, not a host name). The Ribbon client is used to create a full physical address. See RibbonAutoConfiguration for details of how the RestTemplate is set up.

2.4 Spring WebClient as a Load Balancer Client

WebClient can be automatically configured to use the LoadBalancerClient. -To create a load-balanced WebClient, create a WebClient.Builder @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@Configuration
+To create a load-balanced WebClient, create a WebClient.Builder @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@Configuration
 public class MyConfiguration {
 
-	@Bean
-	@LoadBalanced
+	@Bean
+	@LoadBalanced
 	public WebClient.Builder loadBalancedWebClientBuilder() {
 		return WebClient.builder();
 	}
 }
 
 public class MyClass {
-    @Autowired
+    @Autowired
     private WebClient.Builder webClientBuilder;
 
     public Mono<String> doOtherStuff() {
@@ -194,12 +194,12 @@ You can enable it by adding RestTemplate honors some of the Ribbon configuration values related to retrying failed requests.
 You can use client.ribbon.MaxAutoRetries, client.ribbon.MaxAutoRetriesNextServer, and client.ribbon.OkToRetryOnAllOperations properties.
 If you would like to disable the retry logic with Spring Retry on the classpath, you can set spring.cloud.loadbalancer.retry.enabled=false.
-See the Ribbon documentation for a description of what these properties do.

If you would like to implement a BackOffPolicy in your retries, you need to create a bean of type LoadBalancedRetryFactory and override the createBackOffPolicy method:

@Configuration
+See the Ribbon documentation for a description of what these properties do.

If you would like to implement a BackOffPolicy in your retries, you need to create a bean of type LoadBalancedRetryFactory and override the createBackOffPolicy method:

@Configuration
 public class MyConfiguration {
-    @Bean
+    @Bean
     LoadBalancedRetryFactory retryFactory() {
         return new LoadBalancedRetryFactory() {
-            @Override
+            @Override
             public BackOffPolicy createBackOffPolicy(String service) {
         		return new ExponentialBackOffPolicy();
         	}
@@ -207,26 +207,26 @@ See the 
[Note]Note

client in the preceding examples should be replaced with your Ribbon client’s name.

If you want to add one or more RetryListener implementations to your retry functionality, you need to create a bean of type LoadBalancedRetryListenerFactory and return the RetryListener array -you would like to use for a given service, as shown in the following example:

@Configuration
+you would like to use for a given service, as shown in the following example:

@Configuration
 public class MyConfiguration {
-    @Bean
+    @Bean
     LoadBalancedRetryListenerFactory retryListenerFactory() {
         return new LoadBalancedRetryListenerFactory() {
-            @Override
+            @Override
             public RetryListener[] createRetryListeners(String service) {
                 return new RetryListener[]{new RetryListener() {
-                    @Override
+                    @Override
                     public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
                         //TODO Do you business...
                         return true;
                     }
 
-                    @Override
+                    @Override
                      public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
                         //TODO Do you business...
                     }
 
-                    @Override
+                    @Override
                     public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
                         //TODO Do you business...
                     }
@@ -235,28 +235,28 @@ you would like to use for a given service, as shown in the following example:

2.5 Multiple RestTemplate objects

If you want a RestTemplate that is not load-balanced, create a RestTemplate bean and inject it. -To access the load-balanced RestTemplate, use the @LoadBalanced qualifier when you create your @Bean, as shown in the following example:\

@Configuration
+To access the load-balanced RestTemplate, use the @LoadBalanced qualifier when you create your @Bean, as shown in the following example:\

@Configuration
 public class MyConfiguration {
 
-    @LoadBalanced
-    @Bean
+    @LoadBalanced
+    @Bean
     RestTemplate loadBalanced() {
         return new RestTemplate();
     }
 
-    @Primary
-    @Bean
+    @Primary
+    @Bean
     RestTemplate restTemplate() {
         return new RestTemplate();
     }
 }
 
 public class MyClass {
-    @Autowired
+    @Autowired
     private RestTemplate restTemplate;
 
-    @Autowired
-    @LoadBalanced
+    @Autowired
+    @LoadBalanced
     private RestTemplate loadBalanced;
 
     public String doOtherStuff() {
@@ -267,7 +267,7 @@ To access the load-balanced RestTemplate, use the <
         return restTemplate.getForObject("https://example.com", String.class);
     }
 }
[Important]Important

Notice the use of the @Primary annotation on the plain RestTemplate declaration in the preceding example to disambiguate the unqualified @Autowired injection.

[Tip]Tip

If you see errors such as java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89, try injecting RestOperations or setting spring.aop.proxyTargetClass=true.

2.6 Spring WebFlux WebClient as a Load Balancer Client

WebClient can be configured to use the LoadBalancerClient. LoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath. The following example shows how to configure a WebClient to use load balancer:

public class MyClass {
-    @Autowired
+    @Autowired
     private LoadBalancerExchangeFilterFunction lbFunction;
 
     public Mono<String> doOtherStuff() {
@@ -309,19 +309,19 @@ You can also disable the creation of these beans by setting 

2.9.1 Feature types

There are two types of 'features': abstract and named.

Abstract features are features where an interface or abstract class is defined and that an implementation the creates, such as DiscoveryClient, LoadBalancerClient, or LockService. The abstract class or interface is used to find a bean of that type in the context. -The version displayed is bean.getClass().getPackage().getImplementationVersion().

Named features are features that do not have a particular class they implement, such as "Circuit Breaker", "API Gateway", "Spring Cloud Bus", and others. These features require a name and a bean type.

2.9.2 Declaring features

Any module can declare any number of HasFeature beans, as shown in the following examples:

@Bean
+The version displayed is bean.getClass().getPackage().getImplementationVersion().

Named features are features that do not have a particular class they implement, such as "Circuit Breaker", "API Gateway", "Spring Cloud Bus", and others. These features require a name and a bean type.

2.9.2 Declaring features

Any module can declare any number of HasFeature beans, as shown in the following examples:

@Bean
 public HasFeatures commonsFeatures() {
   return HasFeatures.abstractFeatures(DiscoveryClient.class, LoadBalancerClient.class);
 }
 
-@Bean
+@Bean
 public HasFeatures consulFeatures() {
   return HasFeatures.namedFeatures(
     new NamedFeature("Spring Cloud Bus", ConsulBusAutoConfiguration.class),
     new NamedFeature("Circuit Breaker", HystrixCommandAspect.class));
 }
 
-@Bean
+@Bean
 HasFeatures localFeatures() {
   return HasFeatures.builder()
       .abstractFeature(Foo.class)
diff --git a/2.1.x/spring-cloud-commons.xml b/2.1.x/spring-cloud-commons.xml
index 19fc3716..54277145 100644
--- a/2.1.x/spring-cloud-commons.xml
+++ b/2.1.x/spring-cloud-commons.xml
@@ -4,7 +4,7 @@
 
 
 Cloud Native Applications
-2019-06-06
+2019-06-28