Class Utils


  • public class Utils
    extends Object
    Carbon utility methods.
    Since:
    1.0.0
    • 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. If carbon.home system property is not found, gets the CARBON_HOME_ENV system 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. If wso2.runtime.path system property is not found, gets the RUNTIME_PATH_ENV system 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 name
        defaultValue - 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 name
        defaultValue - 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, the checkSecurity method 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