Class Configuration

java.lang.Object
io.deephaven.configuration.PropertyFile
io.deephaven.configuration.Configuration

public abstract class Configuration extends PropertyFile
Utility class to provide an enhanced view and common access point for java properties files, as well as common configuration pieces.
  • Field Details

  • Constructor Details

  • Method Details

    • getInstance

      public static Configuration getInstance()
      Get the default Configuration instance.
      Returns:
      the single instance of Configuration allowed in an application
    • getNamed

      public static Configuration getNamed(@NotNull @NotNull String name) throws ConfigurationException
      Get the Configuration for the specified name.
      Parameters:
      name - the name of the configuration to load
      Returns:
      the named configuration.
      Throws:
      ConfigurationException - if the named configuration could not be loaded.
    • reset

      public static void reset()
      Clear all currently loaded Configurations so that they may be loaded anew.
    • reset

      public static void reset(@NotNull @NotNull String name)
      Clear the specified named Configuration so it may be loaded anew.
      Parameters:
      name - the Configuration to clear.
    • newStandaloneConfiguration

      public static Configuration newStandaloneConfiguration()
      Create a new, non-cached, default Configuration instance.
      Returns:
      a new Configuration instance, guaranteed to not be cached.
    • newStandaloneConfiguration

      public static Configuration newStandaloneConfiguration(@NotNull @NotNull Supplier<ConfigurationContext> contextSupplier)
      Create a new, non-cached, default Configuration instance.
      Parameters:
      contextSupplier - the supplier for ConfigurationContext
      Returns:
      a new Configuration instance, guaranteed to not be cached.
    • newStandaloneConfiguration

      public static Configuration newStandaloneConfiguration(@NotNull @NotNull String name)
      Create a new, non-cached, named Configuration instance.
      Parameters:
      name - the configuration name
      Returns:
      a new Configuration instance, guaranteed to not be cached.
    • newStandaloneConfiguration

      public static Configuration newStandaloneConfiguration(@NotNull @NotNull String name, @NotNull @NotNull Supplier<ConfigurationContext> contextSupplier)
      Create a new, non-cached, named Configuration instance.
      Parameters:
      name - the configuration name
      contextSupplier - the supplier for ConfigurationContext
      Returns:
      a new Configuration instance, guaranteed to not be cached.
    • init

      protected void init()
      Initialize the configuration. This will be sensitive to any system properties that configure the property file path.
    • getContextKeyValues

      @NotNull public @NotNull Collection<String> getContextKeyValues()
      Return the configuration contexts for this process. This is the list of properties that may have been used to parse the configuration file. If the configuration has not been parsed, this collection may be empty. This collection will be immutable.
      Returns:
      the configuration contexts.
    • lookupPath

      public String lookupPath(String propertyName)
      Treat the system property propertyName as a path, and perform substitution with expandLinuxPath(String).
      Parameters:
      propertyName - system property containing a path
      Returns:
      The value of property propertyName after the manipulations.
    • expandLinuxPath

      public static String expandLinuxPath(String path)
      Expand the Linux-style path.
      • Change linux-style absolute paths to platform independent absolute. If the path starts with "/", replace "/" with the current directory's root (e.g. "C:\" on Windows.
      • If the path begins with "~/", then replace the ~ with the user.home system property.
      • If the path does not begin with "~/", then replace all occurrences of ~ with system property user.name.
      • Make sure the path ends in File.separator.
      Parameters:
      path - the path to be adjusted
      Returns:
      the path with substitutions performed
    • getServerTimezone

      public TimeZone getServerTimezone()
      Returns:
      the TimeZone the server is running in
    • reloadProperties

      public String reloadProperties() throws IOException, ConfigurationException
      Reload properties, then update with all system properties (properties set in System take precedence).
      Returns:
      the property file used
      Throws:
      IOException - if the property stream cannot be processed
      ConfigurationException - if the property stream cannot be opened
    • determinePropertyFile

      protected abstract String determinePropertyFile()
    • main

      public static void main(String[] args)
      The following main method compares two directories of prop files and outputs a CSV report of the differences. Usually run before the release of a new version into prod
      Parameters:
      args - dir1 dir2 outFile.csv