Package org.openbravo.client.application
Class CachedPreference
- java.lang.Object
-
- org.openbravo.client.application.CachedPreference
-
- All Implemented Interfaces:
Serializable
@SessionScoped public class CachedPreference extends Object implements Serializable
This class is used to keep the value of some preferences in cache during the life cycle of a session, avoiding the time spent to compute the preference value. The preference values that can be cached by this class are those defined at System level.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALLOW_UNPAGED_DS_MANUAL_REQUEST
static String
ALLOW_UNSECURED_DS_REQUEST
static String
ALLOW_WHERE_PARAMETER
static String
RANK_NORMALIZATION
-
Constructor Summary
Constructors Constructor Description CachedPreference()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCachedPreference(String propertyName)
Adds a new preference into the set of preferences whose value is stored in cache.String
getPreferenceValue(String propertyName)
It returns a String with the value of the preference whose related property name is entered as parameter.String
getPreferenceValueAndStoreInCache(String propertyName)
Return the Preference value and store it into the cached variablevoid
invalidatePreferenceValue(String propertyName)
Invalidates the cached value of the preference.boolean
isCachedPreference(String propertyName)
Checks if the preference related to the property name entered as parameter is contained in the list of cached preferences.void
setPreferenceValue(String propertyName, String preferenceValue)
Sets the cached value of the preference.
-
-
-
Field Detail
-
ALLOW_UNPAGED_DS_MANUAL_REQUEST
public static final String ALLOW_UNPAGED_DS_MANUAL_REQUEST
- See Also:
- Constant Field Values
-
ALLOW_UNSECURED_DS_REQUEST
public static final String ALLOW_UNSECURED_DS_REQUEST
- See Also:
- Constant Field Values
-
ALLOW_WHERE_PARAMETER
public static final String ALLOW_WHERE_PARAMETER
- See Also:
- Constant Field Values
-
RANK_NORMALIZATION
public static final String RANK_NORMALIZATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPreferenceValue
public String getPreferenceValue(String propertyName)
It returns a String with the value of the preference whose related property name is entered as parameter. In case the value is not stored in cache, then the value will be retrieved from database.- Parameters:
propertyName
- The name of the property related to the preference- Returns:
- A String with the value of the cached preference
-
getPreferenceValueAndStoreInCache
public String getPreferenceValueAndStoreInCache(String propertyName)
Return the Preference value and store it into the cached variable- Parameters:
propertyName
- The name of the property related to the preference- Returns:
- The preference value of the propertyName given
-
isCachedPreference
public boolean isCachedPreference(String propertyName)
Checks if the preference related to the property name entered as parameter is contained in the list of cached preferences.- Parameters:
propertyName
- The name of the property related to the preference- Returns:
- true if the preference related to the property name is a cached preference, false otherwise
-
setPreferenceValue
public void setPreferenceValue(String propertyName, String preferenceValue)
Sets the cached value of the preference. This method is defined as synchronized in order to avoid concurrency problems.- Parameters:
propertyName
- The name of the property related to the preferencepreferenceValue
- String with the value assigned to the preference
-
invalidatePreferenceValue
public void invalidatePreferenceValue(String propertyName)
Invalidates the cached value of the preference. This method is defined as synchronized in order to avoid concurrency problems.- Parameters:
propertyName
- The name of the property related to the preference
-
addCachedPreference
public void addCachedPreference(String propertyName)
Adds a new preference into the set of preferences whose value is stored in cache.- Parameters:
propertyName
- The name of the property related to the preference to be cached
-
-