Package org.apache.solr.common.util
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 Summary
Constructors Constructor Description EnvUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static StringenvNameToSyspropName(String envName)static SortedMap<String,String>getProperties()Get all Solr system properties as a sorted mapstatic StringgetProperty(String key)Get a property as stringstatic StringgetProperty(String key, String defaultValue)Get a property as string with a fallback value.static BooleangetPropertyAsBool(String key)Get property as booleanstatic BooleangetPropertyAsBool(String key, Boolean defaultValue)Get property as boolean, or default valuestatic IntegergetPropertyAsInteger(String key)Get property as integerstatic IntegergetPropertyAsInteger(String key, Integer defaultValue)Get property as integer, or default valuestatic List<String>getPropertyAsList(String key)Get comma separated strings from sysprop as Liststatic List<String>getPropertyAsList(String key, List<String> defaultValue)Get comma separated strings from sysprop as List, or default valuestatic LonggetPropertyAsLong(String key)Get property as longstatic LonggetPropertyAsLong(String key, Long defaultValue)Get property as long, or default valuestatic voidsetProperty(String key, String value)Set a system property.
-
-
-
Method Detail
-
getProperties
public static SortedMap<String,String> getProperties()
Get all Solr system properties as a sorted map
-
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, Long defaultValue)
Get property as long, or default value
-
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 toSystem.setProperty(String, String)
-
-