Class CmsFormatterConfigurationCache
- java.lang.Object
-
- org.opencms.ade.configuration.formatters.CmsFormatterConfigurationCache
-
- All Implemented Interfaces:
I_CmsGlobalConfigurationCache
public class CmsFormatterConfigurationCache extends java.lang.Object implements I_CmsGlobalConfigurationCache
A cache object which holds a collection of formatter configuration beans read from the VFS.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.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
N_FORMATTER_KEY
Node name for the FormatterKey node.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 Summary
Constructors Constructor Description CmsFormatterConfigurationCache(CmsObject cms, java.lang.String name)
Creates a new formatter configuration cache instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
N_FORMATTER_KEY
public static final java.lang.String N_FORMATTER_KEY
Node name for the FormatterKey node.- See Also:
- Constant Field Values
-
RELOAD_MARKER
public static final CmsUUID RELOAD_MARKER
A UUID which is used to mark the configuration cache for complete reloading.
-
TYPE_FLEX_FORMATTER
public static final java.lang.String TYPE_FLEX_FORMATTER
The resource type for macro formatters.- See Also:
- Constant Field Values
-
TYPE_FORMATTER_CONFIG
public static final java.lang.String TYPE_FORMATTER_CONFIG
The resource type for formatter configurations.- See Also:
- Constant Field Values
-
TYPE_MACRO_FORMATTER
public static final java.lang.String TYPE_MACRO_FORMATTER
The resource type for macro formatters.- See Also:
- Constant Field Values
-
TYPE_SETTINGS_CONFIG
public static final java.lang.String TYPE_SETTINGS_CONFIG
Type name for setting configurations.- See Also:
- Constant Field Values
-
UPDATE_DELAY_MILLIS
protected static int UPDATE_DELAY_MILLIS
The delay to use for updating the formatter cache, in seconds.
-
-
Constructor Detail
-
CmsFormatterConfigurationCache
public CmsFormatterConfigurationCache(CmsObject cms, java.lang.String name) throws CmsException
Creates a new formatter configuration cache instance.- Parameters:
cms
- the CMS context to usename
- the cache name- Throws:
CmsException
- if something goes wrong
-
-
Method Detail
-
addWaitHandle
public void addWaitHandle(CmsWaitHandle handle)
Adds a wait handle to the list of wait handles.- Parameters:
handle
- the handle to add
-
clear
public void clear()
Description copied from interface:I_CmsGlobalConfigurationCache
Clears the cache.- Specified by:
clear
in interfaceI_CmsGlobalConfigurationCache
- See Also:
I_CmsGlobalConfigurationCache.clear()
-
getName
public java.lang.String getName()
Gets the cache instance name.- Returns:
- the cache instance name
-
getState
public CmsFormatterConfigurationCacheState getState()
Gets the collection of cached formatters.- Returns:
- the collection of cached formatters
-
initialize
public void initialize()
Initializes the cache and installs the update task.
-
performUpdate
public void performUpdate()
The method called by the scheduled update action to update the cache.
-
reload
public void reload()
Reloads the formatter cache.
-
remove
public void remove(CmsPublishedResource pubRes)
Description copied from interface:I_CmsGlobalConfigurationCache
Removes a published resource from the cache.- Specified by:
remove
in interfaceI_CmsGlobalConfigurationCache
- Parameters:
pubRes
- the published resource- See Also:
I_CmsGlobalConfigurationCache.remove(org.opencms.db.CmsPublishedResource)
-
remove
public void remove(CmsResource resource)
Description copied from interface:I_CmsGlobalConfigurationCache
Removes a resource from the cache.- Specified by:
remove
in interfaceI_CmsGlobalConfigurationCache
- Parameters:
resource
- the resource to remove- See Also:
I_CmsGlobalConfigurationCache.remove(org.opencms.file.CmsResource)
-
update
public void update(CmsPublishedResource pubRes)
Description copied from interface:I_CmsGlobalConfigurationCache
Updates the cache entry for the given published resource.NOTE: 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.
- Specified by:
update
in interfaceI_CmsGlobalConfigurationCache
- Parameters:
pubRes
- a published resource- See Also:
I_CmsGlobalConfigurationCache.update(org.opencms.db.CmsPublishedResource)
-
update
public void update(CmsResource resource)
Description copied from interface:I_CmsGlobalConfigurationCache
Updates the cache entry for the given resource.NOTE: 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.
- Specified by:
update
in interfaceI_CmsGlobalConfigurationCache
- Parameters:
resource
- the resource for which the cache entry should be updated- See Also:
I_CmsGlobalConfigurationCache.update(org.opencms.file.CmsResource)
-
waitForUpdate
public void waitForUpdate()
Waits until no update action is scheduled.Should only be used in tests.
-
readFormatter
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.- Parameters:
structureId
- the structure id of the formatter configuration- Returns:
- the formatter bean, or null if no formatter could be read for some reason
-
-