Interface DiscriminatedPropertyAccessor

All Known Implementing Classes:
DefaultDiscriminatedPropertyAccessor

public interface DiscriminatedPropertyAccessor
Finds a discriminated property in the environment for the given basic key, if available. For example, given a basic key of my.company.property, the system will check several keys in the following order:
  1. my.company.application.{applicationId}.property
  2. my.company.tenant.{tenantId}.property
  3. my.company.property
The first value found will be used. The applicationId and tenantId values are informed by DiscriminatedPropertyContext, which is generally set via DiscriminatedPropertyFilter. Any information available in the context will be harvested here in order to create the property key combinations. Either tenantId, applicationId (or both) are supported in the context and best attempt will be made to fashion keys based on the context information available. If no context is provided, then the basic key is used. If no properties are available in the environment, then the default value specified in the instance variable in the ConfigurationProperties annotated bean will be used.

A cache of keys to values is also maintained for performance. This cache is groomed when the component receives a EnvironmentChangeEvent, which generally results from an environment refresh from a Spring Cloud Config server.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    getProperty(String key, Class<?> type, Supplier<Object> defaultValue)
    Fetch a marshalled configuration property instance from the Spring environment
  • Method Details

    • getProperty

      <T> T getProperty(String key, Class<?> type, Supplier<Object> defaultValue)
      Fetch a marshalled configuration property instance from the Spring environment
      Type Parameters:
      T - The type of the marshalled property value
      Parameters:
      key - The basic key to use to check the environment.
      type - The type to marshall the environment value to
      defaultValue - Supplier for the default value taken from the ConfigurationProperties bean instance variable
      Returns:
      The marshalled property value