Class CachedEnvironment


  • @Internal
    public class CachedEnvironment
    extends java.lang.Object
    A "cached environment" is a performance optimization aimed at minimizing the cost of calling System.getenv() or System.getProperties(). The API is therefore a mirror to the equivalent System class calls, except that if "environment caching" is enabled, then all system properties and all environment variables are deemed immutable: they will be queried at application startup once and cached forever. By default, caching is disabled. Should you want to have caching enabled, you must make sure that a call to StaticOptimizations.cacheEnvironment() is made prior to initializing this class.
    Since:
    3.2.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.String> getenv()
      Returns the complete set of environment variables.
      static java.lang.String getenv​(java.lang.String name)
      Returns the value of the requested environment variable.
      static java.lang.String getProperty​(java.lang.String name)
      Returns the system property of the requested name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CachedEnvironment

        public CachedEnvironment()
    • Method Detail

      • getenv

        @Nullable
        public static java.lang.String getenv​(java.lang.String name)
        Returns the value of the requested environment variable. If caching is enabled, the value will be the one computed at startup time: changes won't be visible. If caching is not enabled, this just delegates to System.getenv(java.lang.String).
        Parameters:
        name - the name of the environment variable
        Returns:
        the value of the environment variable
      • getenv

        @NonNull
        public static java.util.Map<java.lang.String,​java.lang.String> getenv()
        Returns the complete set of environment variables. If caching is enabled, the value will be the one computed at startup time: changes won't be visible. If caching is not enabled, this just delegates to System.getenv(java.lang.String).
        Returns:
        the environment variables
      • getProperty

        @Nullable
        public static java.lang.String getProperty​(java.lang.String name)
        Returns the system property of the requested name. If caching is enabled, the value will be the one computed at startup time: changes won't be visible. If caching is not enabled, this just delegates to System.getProperty(String).
        Parameters:
        name - the name of the system property
        Returns:
        the value of the system property