Class EnvUtils

java.lang.Object
org.apache.solr.common.util.EnvUtils

public class EnvUtils extends Object
Provides convenient access to System Properties for Solr. It also converts 'SOLR_FOO' env vars to system properties 'solr.foo', which is done on first access of this class. All Solr code should use this in lieu of JDK equivalents.
  • Constructor Details

    • EnvUtils

      public EnvUtils()
  • Method Details

    • getProperties

      public static SortedMap<String,String> getProperties()
      Get all Solr system properties as a sorted map
    • getProperty

      public static String getProperty(String key)
      Get a property as string
    • getProperty

      public static String getProperty(String key, String defaultValue)
      Get a property as string with a fallback value. All other getProperty* methods use this.
      Parameters:
      key - property key, which treats 'camelCase' the same as 'camel.case'
      defaultValue - fallback value if property is not found
    • getPropertyAsInteger

      public static Integer getPropertyAsInteger(String key)
      Get property as integer
    • getPropertyAsInteger

      public static Integer getPropertyAsInteger(String key, Integer defaultValue)
      Get property as integer, or default value
    • getPropertyAsLong

      public static Long getPropertyAsLong(String key)
      Get property as long
    • getPropertyAsLong

      public static Long getPropertyAsLong(String key, Long defaultValue)
      Get property as long, or default value
    • getPropertyAsBool

      public static Boolean getPropertyAsBool(String key)
      Get property as boolean
    • getPropertyAsBool

      public static Boolean getPropertyAsBool(String key, Boolean defaultValue)
      Get property as boolean, or default value
    • getPropertyAsList

      public static List<String> getPropertyAsList(String key)
      Get comma separated strings from sysprop as List
      Returns:
      list of strings, or null if not found
    • getPropertyAsList

      public static List<String> getPropertyAsList(String key, List<String> defaultValue)
      Get comma separated strings from sysprop as List, or default value
      Returns:
      list of strings, or provided default if not found
    • setProperty

      public static void setProperty(String key, String value)
      Set a system property. Shim to System.setProperty(String, String)
    • envNameToSyspropName

      protected static String envNameToSyspropName(String envName)