Class 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 implements ConfigurationFile capable of loading and parsing the file contents, and pass a ConfigurationFilesCache.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 extends AbstractConfigurationElement, which already provides the logic to parse the structure of an xml-based configuration file.
    Since:
    MicroStrategy Web 9.0.0
    See Also:
    AbstractConfigurationElement
    • Method Detail

      • 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 class CacheBase
        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 class CacheBase
        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 class CacheBase
        Parameters:
        hint - the hint object.
        Returns:
        the key
        Throws:
        CacheException - if somethig gos wrong.
      • 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 interface Cache
        Overrides:
        clear in class CacheBase
        See Also:
        Cache.clear()