From d40b8f3555985a9fae02d7cee409e82bd1e2e3e4 Mon Sep 17 00:00:00 2001 From: Ryan Baxter Date: Tue, 5 Jun 2018 10:15:40 -0400 Subject: [PATCH] Clarify how to make immutable beans refreshable. Fixes #363 --- docs/src/main/asciidoc/spring-cloud-commons.adoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/src/main/asciidoc/spring-cloud-commons.adoc b/docs/src/main/asciidoc/spring-cloud-commons.adoc index c7355258..9672eaec 100644 --- a/docs/src/main/asciidoc/spring-cloud-commons.adoc +++ b/docs/src/main/asciidoc/spring-cloud-commons.adoc @@ -167,6 +167,12 @@ This feature addresses the problem of stateful beans that only get their configu 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. Then, the next time something borrows a connection from the pool, it gets one with the new URL. +Sometimes, it might even be mandatory to apply the `@RefreshScope` +annotation on some beans which can be only initialized once. If a bean +is "immutable", you will have to either annotate the bean with `@RefreshScope` +or specify the classname under the property key +`spring.cloud.refresh.extra-refreshable`. + 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. To force a bean to re-initialize on the next method call, you must invalidate its cache entry.