This topic discusses externalized configuration of Spring Boot for VMware GemFire.

Like Spring Boot, Spring Boot for VMware GemFire supports externalized configuration. For more information about Spring Boot, see the Spring Boot documentation.

Externalized configuration is configuration metadata stored in Spring Boot You can separate concerns by addressing each concern in an individual properties file. Optionally, you can enable any specific property file for only a specific profile. For more information about Spring Boot profiles, see profile in the Spring Boot documentation.

You can do many other powerful things, such as using placeholders in properties, encrypting properties, and so on.

This topic focuses particularly on type safety.

Like Spring Boot, Spring Boot for VMware GemFire provides a hierarchy of classes that captures configuration for several VMware GemFire features in an associated @ConfigurationProperties annotated class. Again, the configuration metadata is specified as well-known, documented properties in one or more Spring Boot files.

For instance, a Spring Boot, VMware GemFire ClientCache application might be configured as follows:

Example 1. Spring Boot containing Spring Data properties for VMware GemFire

# Spring Boot used to configure VMware GemFire

# Configure general cache properties

# Configure ClientCache specific properties

# Configure a log file

# Configure the client's connection Pool to the servers in the cluster[11235],boombox[10334]

You may sometimes 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. You can access any property by using Spring’s Environment abstraction:

Example 2. Using the Spring Environment

class GemFireConfiguration {

    void readConfigurationFromEnvironment(Environment environment) {
        boolean copyOnRead = environment.getProperty("",
            Boolean.TYPE, false);

While using 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, you can now, thanks to Spring Boot for VMware GemFire’s auto-configured configuration processor, access the configuration metadata by using @ConfigurationProperties classes.

To add to the preceding example, you can now do the following:

Example 3. Using GemFireProperties

class MyApplicationComponent {

    private GemFireProperties gemfireProperties;

    public void someMethodUsingGemFireProperties() {

        boolean copyOnRead = this.gemfireProperties.getCache().isCopyOnRead();

        // do something with `copyOnRead`

Given a handle to GemFireProperties, you can access any of the configuration properties that are used to configure VMware GemFire in a Spring context. You need only autowire an instance of GemFireProperties into your application component.

Externalized Configuration of Spring Session

You can access the externalized configuration of Spring Session when you use VMware GemFire as your (HTTP) session state caching provider.

In this case, you need only acquire a reference to an instance of the SpringSessionPropertiesclass.

As shown earlier in this chapter, you can specify Spring Session for VMware GemFire properties as follows:

Example 4. Spring Boot for Spring Session using VMware GemFire as the (HTTP) session state caching provider

# Spring Boot used to configure VMware GemFire as a (HTTP) session state caching provider
# in Spring Session

Then, in your application, you can do something similar to the following example:

Example 5. Using SpringSessionProperties

class MyApplicationComponent {

    private SpringSessionProperties springSessionProperties;

    public void someMethodUsingSpringSessionProperties() {

        String sessionRegionName = this.springSessionProperties

        // do something with `sessionRegionName`
check-circle-line exclamation-circle-line close-line
Scroll to top icon