Class Config


  • public abstract class Config
    extends java.lang.Object
    Main class that is used to load and store hybris platform configuration settings.

    When starting up the hybris Platform the system tries to load the system resource '/project.properties' which is normally inside the platform/ directory or the local.properties which is normally at the config folder of the deployed ear file. This file is a file with entries of the form

             key1=value
             key2=value
             ...
     

    Important:

    1. The configuration file is loaded only once at startup. If you change it manually it may get overridden when using methods to write the file. (Config.setParameter()) This issue may be addressed in a future release.
    • Constructor Summary

      Constructors 
      Constructor Description
      Config()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.String> getAllParameters()
      Returns a copy of all parameters as a key/value pair map.
      static boolean getBoolean​(java.lang.String key, boolean def)  
      static char getChar​(java.lang.String key, char def)  
      static java.lang.String getDatabase()
      Returns the database name.
      static Config.DatabaseName getDatabaseName()  
      static java.lang.String getDatabaseURL()  
      static java.lang.String getDatabaseVersion()  
      static double getDouble​(java.lang.String key, double def)  
      static int getInt​(java.lang.String key, int def)  
      static long getLong​(java.lang.String key, long def)  
      static java.lang.String getParameter​(java.lang.String key)
      Returns a parameter value for a given key.
      static java.util.Map<java.lang.String,​java.lang.String> getParametersByPattern​(java.lang.String pattern)
      Return a copy of all config parameters which starts with the given pattern.
      static java.lang.String getString​(java.lang.String key, java.lang.String def)  
      static boolean isHanaUsed()  
      static boolean isHSQLDBUsed()  
      static boolean isMySQL8Used()  
      static boolean isMySQLUsed()  
      static boolean isOracleUsed()  
      static boolean isPostgreSQLUsed()  
      static boolean isSQLServerUsed()  
      static void setParameter​(java.lang.String key, java.lang.String value)
      Changes a parameter.
      static java.lang.String trim​(java.lang.String value, char[] ignore)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Config

        public Config()
    • Method Detail

      • getParametersByPattern

        public static java.util.Map<java.lang.String,​java.lang.String> getParametersByPattern​(java.lang.String pattern)
        Return a copy of all config parameters which starts with the given pattern.
        Parameters:
        pattern - the pattern to match
        Returns:
        a new Map with the matching key/value pairs
      • getAllParameters

        public static java.util.Map<java.lang.String,​java.lang.String> getAllParameters()
        Returns a copy of all parameters as a key/value pair map.
        Returns:
        a new Map with all key/value pairs
      • getParameter

        public static java.lang.String getParameter​(java.lang.String key)
        Returns a parameter value for a given key.
        Parameters:
        key - the key
        Returns:
        the value mapped to the key or null, if this key was not mapped.
      • getString

        public static java.lang.String getString​(java.lang.String key,
                                                 java.lang.String def)
        Parameters:
        key - the key
        def - the default value
        Returns:
        the value mapped to the key or the specified default value, if this key was not mapped.
      • getChar

        public static char getChar​(java.lang.String key,
                                   char def)
                            throws java.lang.IndexOutOfBoundsException
        Throws:
        java.lang.IndexOutOfBoundsException
      • getBoolean

        public static boolean getBoolean​(java.lang.String key,
                                         boolean def)
      • getInt

        public static int getInt​(java.lang.String key,
                                 int def)
                          throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getLong

        public static long getLong​(java.lang.String key,
                                   long def)
                            throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • getDouble

        public static double getDouble​(java.lang.String key,
                                       double def)
                                throws java.lang.NumberFormatException
        Throws:
        java.lang.NumberFormatException
      • setParameter

        public static void setParameter​(java.lang.String key,
                                        java.lang.String value)
        Changes a parameter.
        Parameters:
        key - the key
        value - the value
      • getDatabase

        public static java.lang.String getDatabase()
        Returns the database name.
        Returns:
        the database name as interned String constant
      • getDatabaseVersion

        public static java.lang.String getDatabaseVersion()
      • isOracleUsed

        public static boolean isOracleUsed()
      • isHSQLDBUsed

        public static boolean isHSQLDBUsed()
      • isMySQLUsed

        public static boolean isMySQLUsed()
      • isMySQL8Used

        public static boolean isMySQL8Used()
      • isSQLServerUsed

        public static boolean isSQLServerUsed()
      • isHanaUsed

        public static boolean isHanaUsed()
      • isPostgreSQLUsed

        public static boolean isPostgreSQLUsed()
      • getDatabaseURL

        public static java.lang.String getDatabaseURL()
      • trim

        public static java.lang.String trim​(java.lang.String value,
                                            char[] ignore)