Edit chapter on 'Externalized Configuration'.
This commit is contained in:
@@ -4,20 +4,21 @@
|
||||
Like Spring Boot itself (see {spring-boot-docs-html}/boot-features-external-config.html[here]),
|
||||
Spring Boot for Apache Geode and Pivotal GemFire (SBDG) supports externalized configuration.
|
||||
|
||||
By externalized configuration, we mean configuration meta-data stored in a Spring Boot
|
||||
By externalized configuration, we mean configuration metadata stored in a Spring Boot
|
||||
{spring-boot-docs-html}/boot-features-external-config.html#boot-features-external-config-application-property-files[`application.properties` file],
|
||||
for instance. Properties can even be delineated by concern, broken out into individual properties files, that are
|
||||
perhaps only enabled by a specific {spring-boot-docs-html}/boot-features-external-config.html#boot-features-external-config-profile-specific-properties[Profile].
|
||||
|
||||
There are many other powerful things you can do, such as use {spring-boot-docs-html}/boot-features-external-config.html#boot-features-external-config-placeholders-in-properties[placeholders]
|
||||
in properties, {spring-boot-docs-html}/boot-features-external-config.html#boot-features-encrypting-properties[encrypt]
|
||||
There are many other powerful things you can do, such as, but not limited to, using
|
||||
{spring-boot-docs-html}/boot-features-external-config.html#boot-features-external-config-placeholders-in-properties[placeholders]
|
||||
in properties, {spring-boot-docs-html}/boot-features-external-config.html#boot-features-encrypting-properties[encrypting]
|
||||
properties, and so on. What we are particularly interested in, in this section, is
|
||||
{spring-boot-docs-html}/boot-features-external-config.html#boot-features-external-config-typesafe-configuration-properties[type-safety].
|
||||
|
||||
Like Spring Boot, Spring Boot for Apache Geode/Pivotal GemFire provides a hierarchy of classes used to capture
|
||||
the configuration of several Apache Geode or Pivotal GemFire features in an associated `@ConfigurationProperties`
|
||||
annotated class. Again, the configuration is specified as well-known, documented properties in 1 or more Spring Boot
|
||||
`application.properties` files.
|
||||
Like Spring Boot, Spring Boot for Apache Geode & Pivotal GemFire provides a hierarchy of classes used to capture
|
||||
configuration for several Apache Geode or Pivotal GemFire features in an associated `@ConfigurationProperties`
|
||||
annotated class. Again, the configuration metadata is specified as well-known, documented properties in 1 or more
|
||||
Spring Boot `application.properties` files.
|
||||
|
||||
For instance, I may have configured my Spring Boot, `ClientCache` application as follows:
|
||||
|
||||
@@ -45,11 +46,11 @@ spring.data.gemfire.pool.locators=10.105.120.16[11235],boombox[10334]
|
||||
----
|
||||
|
||||
There are many other properties a user may use to externalize the configuration of their Spring Boot,
|
||||
Apache Geode application. You may refer to the Spring Data for Apache Geode (SDG) configuration annotations
|
||||
Apache Geode applications. You may refer to the Spring Data for Apache Geode (SDG) configuration annotations
|
||||
{spring-data-geode-javadoc}/org/springframework/data/gemfire/config/annotation/package-frame.html[Javadoc]
|
||||
for specific configuration properties as needed. Specifically, review the "enabling" annotation attributes.
|
||||
for specific configuration properties as needed. Specifically, review the "_enabling_" annotation attributes.
|
||||
|
||||
There may be cases where you require access to the configuration meta-data (specified in properties)
|
||||
There may be cases where you require access to the configuration metadata (specified in properties)
|
||||
in your Spring Boot applications themselves, perhaps to further inspect or act on a particular configuration setting.
|
||||
|
||||
Of course, you can access any property using Spring's {spring-framework-javadoc}/org/springframework/core/env/Environment.html[`Environment`] abstraction,
|
||||
@@ -58,12 +59,12 @@ like so:
|
||||
.Using the Spring `Enviornment
|
||||
[source,java]
|
||||
----
|
||||
boolean copyOnRead = environment.getProperty("spring.data.gemfire.cache.copy-on-read", Boolean.TYPE, false);
|
||||
boolean copyOnRead = environment.getProperty("spring.data.gemfire.cache.copy-on-read", Boolean.TYPE, false);
|
||||
----
|
||||
|
||||
While using the `Environment` is a nice approach, you might need access to additional properties or want to access
|
||||
the property values in a type-safe manner. Therefore, it is now possible, thanks to SBDG's auto-configured
|
||||
configuration processor, to access the configuration meta-data using provided `@ConfigurationProperties` classes.
|
||||
configuration processor, to access the configuration metadata using provided `@ConfigurationProperties` classes.
|
||||
|
||||
Following on to our example above, I can now do the following:
|
||||
|
||||
@@ -101,7 +102,7 @@ A complete reference to the SBDG provided `@ConfigurationProperties` classes and
|
||||
The same capability applies to accessing the externalized configuration of Spring Session when using either
|
||||
Apache Geode or Pivotal GemFire as your (HTTP) Session state caching provider.
|
||||
|
||||
In this case, you simply only need to acquire a handle to an instance of the
|
||||
In this case, you simply only need to acquire a reference to an instance of the
|
||||
{spring-boot-data-geode-javadoc}/org/springframework/geode/boot/autoconfigure/configuration/SpringSessionProperties.html[`SpringSessionProperties`]
|
||||
class.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user