public class CmsFormatterConfigurationCache extends java.lang.Object implements I_CmsGlobalConfigurationCache
This class does not immediately update the cached formatter collection when changes in the VFS occur, but instead schedules an update action with a slight delay, so that if many formatters are changed in a short time, only one update operation is needed.
Two instances of this cache are needed, one for the Online project and one for Offline projects.
| Modifier and Type | Field and Description |
|---|---|
static CmsUUID |
RELOAD_MARKER
A UUID which is used to mark the configuration cache for complete reloading.
|
static java.lang.String |
TYPE_FLEX_FORMATTER
The resource type for macro formatters.
|
static java.lang.String |
TYPE_FORMATTER_CONFIG
The resource type for formatter configurations.
|
static java.lang.String |
TYPE_MACRO_FORMATTER
The resource type for macro formatters.
|
static java.lang.String |
TYPE_SETTINGS_CONFIG
Type name for setting configurations.
|
protected static int |
UPDATE_DELAY_MILLIS
The delay to use for updating the formatter cache, in seconds.
|
| Constructor and Description |
|---|
CmsFormatterConfigurationCache(CmsObject cms,
java.lang.String name)
Creates a new formatter configuration cache instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addWaitHandle(CmsWaitHandle handle)
Adds a wait handle to the list of wait handles.
|
void |
clear()
Clears the cache.
|
java.lang.String |
getName()
Gets the cache instance name.
|
CmsFormatterConfigurationCacheState |
getState()
Gets the collection of cached formatters.
|
void |
initialize()
Initializes the cache and installs the update task.
|
void |
performUpdate()
The method called by the scheduled update action to update the cache.
|
protected I_CmsFormatterBean |
readFormatter(CmsUUID structureId)
Reads a formatter given its structure id and returns it, or null if the formatter couldn't be read.
|
void |
reload()
Reloads the formatter cache.
|
void |
remove(CmsPublishedResource pubRes)
Removes a published resource from the cache.
|
void |
remove(CmsResource resource)
Removes a resource from the cache.
|
void |
update(CmsPublishedResource pubRes)
Updates the cache entry for the given published resource.
|
void |
update(CmsResource resource)
Updates the cache entry for the given resource.
|
void |
waitForUpdate()
Waits until no update action is scheduled.
|
public static final CmsUUID RELOAD_MARKER
public static final java.lang.String TYPE_FLEX_FORMATTER
public static final java.lang.String TYPE_FORMATTER_CONFIG
public static final java.lang.String TYPE_MACRO_FORMATTER
public static final java.lang.String TYPE_SETTINGS_CONFIG
protected static int UPDATE_DELAY_MILLIS
public CmsFormatterConfigurationCache(CmsObject cms, java.lang.String name) throws CmsException
cms - the CMS context to usename - the cache nameCmsException - if something goes wrongpublic void addWaitHandle(CmsWaitHandle handle)
handle - the handle to addpublic void clear()
I_CmsGlobalConfigurationCacheclear in interface I_CmsGlobalConfigurationCacheI_CmsGlobalConfigurationCache.clear()public java.lang.String getName()
public CmsFormatterConfigurationCacheState getState()
public void initialize()
public void performUpdate()
public void reload()
public void remove(CmsPublishedResource pubRes)
I_CmsGlobalConfigurationCacheremove in interface I_CmsGlobalConfigurationCachepubRes - the published resourceI_CmsGlobalConfigurationCache.remove(org.opencms.db.CmsPublishedResource)public void remove(CmsResource resource)
I_CmsGlobalConfigurationCacheremove in interface I_CmsGlobalConfigurationCacheresource - the resource to removeI_CmsGlobalConfigurationCache.remove(org.opencms.file.CmsResource)public void update(CmsPublishedResource pubRes)
I_CmsGlobalConfigurationCacheNOTE: Cache implementations should not directly read the updated resource in this method because it might interfere with other caches. Instead, the resource should be marked as updated and read the next time the cache is queried.
update in interface I_CmsGlobalConfigurationCachepubRes - a published resourceI_CmsGlobalConfigurationCache.update(org.opencms.db.CmsPublishedResource)public void update(CmsResource resource)
I_CmsGlobalConfigurationCacheNOTE: Cache implementations should not directly read the updated resource in this method because it might interfere with other caches. Instead, the resource should be marked as updated and read the next time the cache is queried.
update in interface I_CmsGlobalConfigurationCacheresource - the resource for which the cache entry should be updatedI_CmsGlobalConfigurationCache.update(org.opencms.file.CmsResource)public void waitForUpdate()
Should only be used in tests.
protected I_CmsFormatterBean readFormatter(CmsUUID structureId)
structureId - the structure id of the formatter configuration