Class CacheProvider


  • public class CacheProvider
    extends Object
    Provides caching directories to the appNG platform and to appNG applications. Both types of caches provide a dedicated directory layout per site and application. The platform cache caches application-specific Resources. Resources should be cached by calling Resources.dumpToCache(org.appng.api.model.ResourceType...). The application cache may be used by applications and provides a location in the file system where instance-specific files can be cached. These are usually artifacts which are based on some source data stored in a database. The cache is not a persistent data storage and must not be used for unrecoverable data.
    Author:
    Matthias Herlitzius
    • Constructor Detail

      • CacheProvider

        public CacheProvider​(Properties platformConfig)
        Creates a new CacheProvider. Retrieves the directory layout from the platform configuration.
        Parameters:
        platformConfig - The platform configuration. Contains values for keys defined in Platform.Property.
      • CacheProvider

        public CacheProvider​(Properties platformConfig,
                             boolean changeOwner)
        Creates a new CacheProvider. Retrieves the directory layout from the platform configuration.
        Parameters:
        platformConfig - The platform configuration. Contains values for keys defined in Platform.Property.
        changeOwner - if set to true and we're running on *nix, a recursive chown command is being executed for the cache folder
    • Method Detail

      • clearCache

        public void clearCache​(Site site)
        Clears both the platform cache and the application cache for the given site.
        Parameters:
        site - The site which caches are cleared.
      • clearCache

        public void clearCache​(Site site,
                               String application)
        Clears both the platform cache and the application cache for the specified application of the specified site.
        Parameters:
        site -
        application - The application which caches are cleared. The application must be assigned to the aforementioned site. The caches of the same application assigned to other sites will not be cleared.
      • getCache

        protected File getCache()
        Returns the overall cache root directory.
        Returns:
        the overall cache root directory
      • getPlatformCache

        protected File getPlatformCache()
        Returns the root directory of the platform cache.
        Returns:
        the root directory of the platform cache
      • getPlatformCache

        protected File getPlatformCache​(Nameable site)
        Returns the root platform cache directory for a site.
        Parameters:
        site -
        Returns:
        the root platform cache directory for a site
      • getPlatformCache

        protected File getPlatformCache​(String site)
        Returns the root platform cache directory for a site.
        Parameters:
        site -
        Returns:
        the root platform cache directory for a site
      • getPlatformCache

        public File getPlatformCache​(Nameable site,
                                     Nameable application)
        Returns the root platform cache directory for an application.
        Parameters:
        site -
        application -
        Returns:
        the root platform cache directory for an application
      • getPlatformCache

        protected File getPlatformCache​(String site,
                                        String application)
        Returns the root platform cache directory for an application.
        Parameters:
        site -
        application -
        Returns:
        the root platform cache directory for an application
      • getRelativePlatformCache

        public String getRelativePlatformCache​(Nameable site,
                                               Nameable application)
        Returns the relative platform cache directory for an application.
        Parameters:
        site -
        application -
        Returns:
        the relative platform cache directory for an application
      • getApplicationCache

        protected File getApplicationCache()
        Returns the root directory of the application cache.
        Returns:
        the root directory of the application cache
      • getApplicationCache

        protected File getApplicationCache​(Nameable site)
        Returns the root application cache directory for a site.
        Parameters:
        site -
        Returns:
        the root application cache directory for a site
      • getApplicationCache

        protected File getApplicationCache​(String site)
        Returns the root application cache directory for a site.
        Parameters:
        site -
        Returns:
        the root application cache directory for a site
      • getApplicationCache

        protected File getApplicationCache​(Nameable site,
                                           Nameable application)
        Returns the root application cache directory for an application.
        Parameters:
        site -
        application -
        Returns:
        the root application cache directory for an application
      • getApplicationCache

        protected File getApplicationCache​(String site,
                                           String application)
        Returns the root application cache directory for an application.
        Parameters:
        site -
        application -
        Returns:
        the root application cache directory for an application
      • getImageCache

        public File getImageCache​(Nameable site,
                                  Nameable application)
        Returns the root image cache directory for an application. The image cache directory is located within the application cache directory.
        Parameters:
        site -
        application -
        Returns:
        the root image cache directory for an application
      • getImageCache

        protected File getImageCache​(String site,
                                     String application)
        Returns the root image cache directory for an application. The image cache directory is located within the application cache directory.
        Parameters:
        site -
        application -
        Returns:
        the root image cache directory for an application