Package com.microstrategy.utils.config
Class ConfigurationFilesCache
- java.lang.Object
-
- com.microstrategy.utils.cache.CacheBase
-
- com.microstrategy.utils.cache.CustomizationsAwareCache
-
- com.microstrategy.utils.config.ConfigurationFilesCache
-
- All Implemented Interfaces:
Cache
,java.util.Observer
public class ConfigurationFilesCache extends CustomizationsAwareCache
This is the Cache of configuration files. To read the settings from a configuration file, clients create a class that implementsConfigurationFile
capable of loading and parsing the file contents, and pass aConfigurationFilesCache.ConfigurationFileCacheHint
to this cache with their class and file location information, for example:
CacheHint hint = new ConfigurationFileCacheHint("/WEB-INF/xml/myConfigFile.xml", MyConfigClass.class); MyConfigClass config = ConfigurationFilesCache.getInstance().get(hint);
It provides a static helper method to accomplish the same:
MyConfigClass config = ConfigurationFilesCache.getConfiguration("/WEB-INF/xml/myConfigFile.xml", MyConfigClass.class);
Typically the configuration class simply extendsAbstractConfigurationElement
, which already provides the logic to parse the structure of an xml-based configuration file.- Since:
- MicroStrategy Web 9.0.0
- See Also:
AbstractConfigurationElement
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConfigurationFilesCache.ConfigurationFileCacheHint
This is the CacheHint for the ConfigurationFilesCache.
-
Field Summary
-
Fields inherited from class com.microstrategy.utils.cache.CacheBase
alias, DEFAULT_FILE_REFRESH_TIME, DEFAULT_REFRESH_TIME, DEFAULT_STATISTIC_TIME, DEFAULT_SYS_TIMEOUT, DEFAULT_USER_TIMEOUT, NO_KEY, NO_REFRESH, NO_STATISTIC, NO_TIMEOUT
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the HashSet and other caches, will be called when destroying the sevletstatic ConfigurationFile
getConfiguration(java.lang.String filePath, java.lang.Class configClass)
static ConfigurationFilesCache
getInstance()
protected java.lang.Object
getKey(CacheHint hint)
Overridable.protected java.lang.Object
load(CacheHint hint)
Overridable.protected java.lang.Object
reLoad(CacheHint hint, java.lang.Object ob)
Overridable.static void
removeConfiguration(java.lang.String filePath, java.lang.Class configClass)
This method when called will remove the ConfigurationFileCacheHint from the ConfigurationFileCache-
Methods inherited from class com.microstrategy.utils.cache.CustomizationsAwareCache
update
-
Methods inherited from class com.microstrategy.utils.cache.CacheBase
canUpdate, close, configure, contains, delete, get, getName, getRefreshTime, getStatisticTime, getTimeout, getWithoutRefresh, logStatistic, onHintClose, onTimer, put, refresh, remove, save, setRefreshTime, setStatisticTime, setTimeout, size, store, unLoad
-
-
-
-
Method Detail
-
getInstance
public static ConfigurationFilesCache getInstance()
-
reLoad
protected java.lang.Object reLoad(CacheHint hint, java.lang.Object ob) throws CacheException
Description copied from class:CacheBase
Overridable. Re-populates cached object with data from persistent storage. Implementation of this method can re-load the object "in-place" or it can create another object.- Overrides:
reLoad
in classCacheBase
- Parameters:
hint
- the hint object.- Returns:
- the object or null.
- Throws:
CacheException
- if somethig gos wrong.
-
load
protected java.lang.Object load(CacheHint hint) throws CacheException
Description copied from class:CacheBase
Overridable. Creates a new cached object instance and populates it with data from the persistent storage. In case the object not found in the persistent storage the implementation can return either null or a dummy object.- Specified by:
load
in classCacheBase
- Parameters:
hint
- the hint object.- Returns:
- the object or null.
- Throws:
CacheException
- if somethig gos wrong.
-
getKey
protected java.lang.Object getKey(CacheHint hint) throws CacheException
Description copied from class:CacheBase
Overridable. Extracts from the hint object the key that shall be used to identify the cached object.- Specified by:
getKey
in classCacheBase
- Parameters:
hint
- the hint object.- Returns:
- the key
- Throws:
CacheException
- if somethig gos wrong.
-
getConfiguration
public static ConfigurationFile getConfiguration(java.lang.String filePath, java.lang.Class configClass) throws CacheException
- Throws:
CacheException
-
removeConfiguration
public static void removeConfiguration(java.lang.String filePath, java.lang.Class configClass)
This method when called will remove the ConfigurationFileCacheHint from the ConfigurationFileCache
-
clear
public void clear()
Clear the HashSet and other caches, will be called when destroying the sevlet- Specified by:
clear
in interfaceCache
- Overrides:
clear
in classCacheBase
- See Also:
Cache.clear()
-
-