Package org.appng.core.model
Class CacheProvider
- java.lang.Object
-
- org.appng.core.model.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-specificResource
s. Resources should be cached by callingResources.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 Summary
Constructors Constructor Description CacheProvider(Properties platformConfig)
Creates a new CacheProvider.CacheProvider(Properties platformConfig, boolean changeOwner)
Creates a new CacheProvider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCache(Site site)
Clears both the platform cache and the application cache for the given site.void
clearCache(Site site, String application)
Clears both the platform cache and the application cache for the specified application of the specified site.protected File
getApplicationCache()
Returns the root directory of the application cache.protected File
getApplicationCache(String site)
Returns the root application cache directory for a site.protected File
getApplicationCache(String site, String application)
Returns the root application cache directory for an application.protected File
getApplicationCache(Nameable site)
Returns the root application cache directory for a site.protected File
getApplicationCache(Nameable site, Nameable application)
Returns the root application cache directory for an application.protected File
getCache()
Returns the overall cache root directory.protected File
getImageCache(String site, String application)
Returns the root image cache directory for an application.File
getImageCache(Nameable site, Nameable application)
Returns the root image cache directory for an application.protected File
getPlatformCache()
Returns the root directory of the platform cache.protected File
getPlatformCache(String site)
Returns the root platform cache directory for a site.protected File
getPlatformCache(String site, String application)
Returns the root platform cache directory for an application.protected File
getPlatformCache(Nameable site)
Returns the root platform cache directory for a site.File
getPlatformCache(Nameable site, Nameable application)
Returns the root platform cache directory for an application.String
getRelativePlatformCache(Nameable site, Nameable application)
Returns the relative platform cache directory for an application.
-
-
-
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 inPlatform.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 inPlatform.Property
.changeOwner
- if set totrue
and we're running on *nix, a recursivechown
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
-
-