Class CmsFormatterConfigurationCache
- All Implemented Interfaces:
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.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Node name for the FormatterKey node.static final CmsUUID
A UUID which is used to mark the configuration cache for complete reloading.static final String
The resource type for macro formatters.static final String
The resource type for formatter configurations.static final String
The resource type for macro formatters.static final String
Type name for setting configurations.protected static int
The delay to use for updating the formatter cache, in seconds. -
Constructor Summary
ConstructorDescriptionCmsFormatterConfigurationCache
(CmsObject cms, String name) Creates a new formatter configuration cache instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addWaitHandle
(CmsWaitHandle handle) Adds a wait handle to the list of wait handles.void
clear()
Clears the cache.getName()
Gets the cache instance name.getState()
Gets the collection of cached formatters.void
Initializes the cache and installs the update task.void
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
Waits until no update action is scheduled.
-
Field Details
-
N_FORMATTER_KEY
Node name for the FormatterKey node.- See Also:
-
RELOAD_MARKER
A UUID which is used to mark the configuration cache for complete reloading. -
TYPE_FLEX_FORMATTER
The resource type for macro formatters.- See Also:
-
TYPE_FORMATTER_CONFIG
The resource type for formatter configurations.- See Also:
-
TYPE_MACRO_FORMATTER
The resource type for macro formatters.- See Also:
-
TYPE_SETTINGS_CONFIG
Type name for setting configurations.- See Also:
-
UPDATE_DELAY_MILLIS
The delay to use for updating the formatter cache, in seconds.
-
-
Constructor Details
-
CmsFormatterConfigurationCache
Creates a new formatter configuration cache instance.- Parameters:
cms
- the CMS context to usename
- the cache name- Throws:
CmsException
- if something goes wrong
-
-
Method Details
-
addWaitHandle
Adds a wait handle to the list of wait handles.- Parameters:
handle
- the handle to add
-
clear
Description copied from interface:I_CmsGlobalConfigurationCache
Clears the cache.- Specified by:
clear
in interfaceI_CmsGlobalConfigurationCache
- See Also:
-
getName
Gets the cache instance name.- Returns:
- the cache instance name
-
getState
Gets the collection of cached formatters.- Returns:
- the collection of cached formatters
-
initialize
Initializes the cache and installs the update task. -
performUpdate
The method called by the scheduled update action to update the cache. -
reload
Reloads the formatter cache. -
remove
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:
-
remove
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:
-
update
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:
-
update
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:
-
waitForUpdate
Waits until no update action is scheduled.Should only be used in tests.
-
readFormatter
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
-