Class AppPropertiesService

java.lang.Object
fr.paris.lutece.portal.service.util.AppPropertiesService

public final class AppPropertiesService extends Object
this class provides management services for properties files
  • Method Details

    • init

      public static void init(String strConfPath)
      Initializes the service
      Parameters:
      strConfPath - The configuration path
    • getProperty

      public static String getProperty(String strProperty)
      Returns the value of a variable defined in the .properties file of the application as a String
      Parameters:
      strProperty - The variable name
      Returns:
      The variable value read in the properties file
    • getProperty

      public static String getProperty(String strProperty, String strDefault)
      Returns the value of a variable defined in the .properties file of the application as a String
      Parameters:
      strProperty - The variable name
      strDefault - The default value which is returned if no value is found for the variable in the .properties file.
      Returns:
      The variable value read in the properties file
    • getPropertyInt

      public static int getPropertyInt(String strProperty, int nDefault)
      Returns the value of a variable defined in the .properties file of the application as an int
      Parameters:
      strProperty - The variable name
      nDefault - The default value which is returned if no value is found for the variable in the le downloadFile .properties. .properties file.
      Returns:
      The variable value read in the properties file
    • getPropertyLong

      public static long getPropertyLong(String strProperty, long lDefault)
      Returns the value of a variable defined in the .properties file of the application as an long
      Parameters:
      strProperty - The variable name
      lDefault - The default value which is returned if no value is found for the variable in the le downloadFile .properties. .properties file.
      Returns:
      The variable value read in the properties file
    • getPropertyBoolean

      public static boolean getPropertyBoolean(String strProperty, boolean bDefault)
      Returns the value of a variable defined in the .properties file of the application as a boolean
      Parameters:
      strProperty - The variable name
      bDefault - The default value which is returned if no value is found for the variable in the le downloadFile .properties. .properties file.
      Returns:
      The variable value read in the properties file
    • getOptionalValue

      public <T> Optional<T> getOptionalValue(String name, Class<T> aClass)
      Return the resolved property value with the specified type for the specified property name from the underlying configuration sources.

      The configuration value is not guaranteed to be cached by the implementation, and may be expensive to compute; therefore, if the returned value is intended to be frequently used, callers should consider storing rather than recomputing it.

      If this method is used very often then consider to locally store the configured value.

      Type Parameters:
      T - The property type
      Parameters:
      propertyName - The configuration property name
      propertyType - The type into which the resolved property value should be converted
      Returns:
      The resolved property value as an Optional wrapping the requested type
      Throws:
      IllegalArgumentException - if the property cannot be converted to the specified type
    • reloadAll

      @Deprecated public static void reloadAll()
      Deprecated.
      Reloads all the properties files
    • reload

      @Deprecated public static void reload(String strFilename)
      Deprecated.
      Reloads a given properties file
      Parameters:
      strFilename - The file name
    • getProperties

      public static Properties getProperties()
      Gets properties
      Returns:
      All properties
      Since:
      version 3.0
    • getPropertiesAsMap

      public static Map<String,String> getPropertiesAsMap()
      Gets all properties as a Map
      Returns:
      a Map of all properties
      Since:
      version 5.0
    • getKeys

      public static List<String> getKeys(String strPrefix)
      Returns a list of keys that match a given prefix.
      Parameters:
      strPrefix - the str prefix
      Returns:
      A list of keys that match the prefix
      Since:
      version 3.0