Package org.wso2.carbon.utils
Class Utils
- java.lang.Object
-
- org.wso2.carbon.utils.Utils
-
public class Utils extends Object
Carbon utility methods.- Since:
- 1.0.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckSecurity()When the java security manager is enabled, thecheckSecuritymethod can be used to protect/prevent methods being executed by unsigned code.static PathgetCarbonConfigHome()This method will return the carbon configuration directory path.static PathgetCarbonHome()Returns the Carbon Home directory path.static List<String>getCarbonRuntimes()Returns a list of WSO2 Carbon Runtime names.static PathgetRuntimeConfigPath()Get the conf path of the runtime.static StringgetRuntimeName()get the current Runtime name.static PathgetRuntimePath()Returns the Runtime Home directory path.static StringgetSystemVariableValue(String variableName, String defaultValue)A utility which allows reading variables from the environment or System properties.static StringgetSystemVariableValue(String variableName, String defaultValue, Class constantClass)A utility which allows reading variables from the environment or System properties.static StringsubstituteVariables(String value)Replace system property holders in the property values.
-
-
-
Method Detail
-
getCarbonConfigHome
public static Path getCarbonConfigHome()
This method will return the carbon configuration directory path. i.e ${carbon.home}/conf- Returns:
- returns the Carbon Configuration directory path
-
getCarbonHome
public static Path getCarbonHome()
Returns the Carbon Home directory path. Ifcarbon.homesystem property is not found, gets theCARBON_HOME_ENVsystem property value and sets to the carbon home.- Returns:
- returns the Carbon Home directory path
-
getRuntimePath
public static Path getRuntimePath()
Returns the Runtime Home directory path. Ifwso2.runtime.pathsystem property is not found, gets theRUNTIME_PATH_ENVsystem property value and sets to the runtime home.- Returns:
- the Runtime Home directory path
-
getRuntimeConfigPath
public static Path getRuntimeConfigPath()
Get the conf path of the runtime.- Returns:
- Path to the conf dir of runtime
-
getRuntimeName
public static String getRuntimeName()
get the current Runtime name.- Returns:
- the Runtime name
-
substituteVariables
public static String substituteVariables(String value)
Replace system property holders in the property values. e.g. Replace ${carbon.home} with value of the carbon.home system property.- Parameters:
value- string value to substitute- Returns:
- String substituted string
-
getSystemVariableValue
public static String getSystemVariableValue(String variableName, String defaultValue)
A utility which allows reading variables from the environment or System properties. If the variable in available in the environment as well as a System property, the System property takes precedence.- Parameters:
variableName- System/environment variable namedefaultValue- default value to be returned if the specified system variable is not specified.- Returns:
- value of the system/environment variable
-
getSystemVariableValue
public static String getSystemVariableValue(String variableName, String defaultValue, Class constantClass)
A utility which allows reading variables from the environment or System properties. If the variable in available in the environment as well as a System property, the System property takes precedence.- Parameters:
variableName- System/environment variable namedefaultValue- default value to be returned if the specified system variable is not specified.constantClass- Class from which the Predefined value should be retrieved if system variable and default value is not specified.- Returns:
- value of the system/environment variable
-
checkSecurity
public static void checkSecurity()
When the java security manager is enabled, thecheckSecuritymethod can be used to protect/prevent methods being executed by unsigned code.
-
getCarbonRuntimes
public static List<String> getCarbonRuntimes() throws IOException
Returns a list of WSO2 Carbon Runtime names.- Returns:
- WSO2 Carbon Runtime names
- Throws:
IOException- if an I/O error occurs
-
-