Class AppPropertiesService
- java.lang.Object
-
- fr.paris.lutece.portal.service.util.AppPropertiesService
-
public final class AppPropertiesService extends java.lang.Objectthis class provides management services for properties files
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.util.List<java.lang.String>getKeys(java.lang.String strPrefix)Returns a list of keys that match a given prefix.<T> java.util.Optional<T>getOptionalValue(java.lang.String name, java.lang.Class<T> aClass)Return the resolved property value with the specified type for the specified property name from the underlying configuration sources.static java.util.PropertiesgetProperties()Gets propertiesstatic java.util.Map<java.lang.String,java.lang.String>getPropertiesAsMap()Gets all properties as a Mapstatic java.lang.StringgetProperty(java.lang.String strProperty)Returns the value of a variable defined in the .properties file of the application as a Stringstatic java.lang.StringgetProperty(java.lang.String strProperty, java.lang.String strDefault)Returns the value of a variable defined in the .properties file of the application as a Stringstatic booleangetPropertyBoolean(java.lang.String strProperty, boolean bDefault)Returns the value of a variable defined in the .properties file of the application as a booleanstatic intgetPropertyInt(java.lang.String strProperty, int nDefault)Returns the value of a variable defined in the .properties file of the application as an intstatic longgetPropertyLong(java.lang.String strProperty, long lDefault)Returns the value of a variable defined in the .properties file of the application as an longstatic voidinit(java.lang.String strConfPath)Initializes the servicestatic voidreload(java.lang.String strFilename)Deprecated.static voidreloadAll()Deprecated.
-
-
-
Method Detail
-
init
public static void init(java.lang.String strConfPath)
Initializes the service- Parameters:
strConfPath- The configuration path
-
getProperty
public static java.lang.String getProperty(java.lang.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 java.lang.String getProperty(java.lang.String strProperty, java.lang.String strDefault)Returns the value of a variable defined in the .properties file of the application as a String- Parameters:
strProperty- The variable namestrDefault- 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(java.lang.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 namenDefault- 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(java.lang.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 namelDefault- 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(java.lang.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 namebDefault- 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> java.util.Optional<T> getOptionalValue(java.lang.String name, java.lang.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 namepropertyType- The type into which the resolved property value should be converted- Returns:
- The resolved property value as an
Optionalwrapping the requested type - Throws:
java.lang.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(java.lang.String strFilename)
Deprecated.Reloads a given properties file- Parameters:
strFilename- The file name
-
getProperties
public static java.util.Properties getProperties()
Gets properties- Returns:
- All properties
- Since:
- version 3.0
-
getPropertiesAsMap
public static java.util.Map<java.lang.String,java.lang.String> getPropertiesAsMap()
Gets all properties as a Map- Returns:
- a Map of all properties
- Since:
- version 5.0
-
getKeys
public static java.util.List<java.lang.String> getKeys(java.lang.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
-
-