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 String
envNameToSyspropName(String envName)
static SortedMap<String,String>
getProperties()
Get all Solr system properties as a sorted mapstatic String
getProperty(String key)
Get a property as stringstatic String
getProperty(String key, String defaultValue)
Get a property as string with a fallback value.static Boolean
getPropertyAsBool(String key)
Get property as booleanstatic Boolean
getPropertyAsBool(String key, Boolean defaultValue)
Get property as boolean, or default valuestatic Integer
getPropertyAsInteger(String key)
Get property as integerstatic Integer
getPropertyAsInteger(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 Long
getPropertyAsLong(String key)
Get property as longstatic Long
getPropertyAsLong(String key, Long defaultValue)
Get property as long, or default valuestatic void
setProperty(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)
-
-