Package org.wso2.carbon.utils
Class Utils
java.lang.Object
org.wso2.carbon.utils.Utils
Carbon utility methods.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidWhen the java security manager is enabled, thecheckSecuritymethod can be used to protect/prevent methods being executed by unsigned code.static PathThis method will return the carbon configuration directory path.static PathReturns the Carbon Home directory path.Returns a list of WSO2 Carbon Runtime names.static PathGet the conf path of the runtime.static Stringget the current Runtime name.static PathReturns 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 Details
-
getCarbonConfigHome
This method will return the carbon configuration directory path. i.e ${carbon.home}/conf- Returns:
- returns the Carbon Configuration directory 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
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
Get the conf path of the runtime.- Returns:
- Path to the conf dir of runtime
-
getRuntimeName
get the current Runtime name.- Returns:
- the Runtime name
-
substituteVariables
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
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
Returns a list of WSO2 Carbon Runtime names.- Returns:
- WSO2 Carbon Runtime names
- Throws:
IOException- if an I/O error occurs
-