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
FieldsModifier and TypeFieldDescriptionstatic final StringNode name for the FormatterKey node.static final CmsUUIDA UUID which is used to mark the configuration cache for complete reloading.static final StringThe resource type for macro formatters.static final StringThe resource type for formatter configurations.static final StringThe resource type for macro formatters.static final StringType name for setting configurations.protected static intThe delay to use for updating the formatter cache, in seconds. -
Constructor Summary
ConstructorsConstructorDescriptionCmsFormatterConfigurationCache(CmsObject cms, String name) Creates a new formatter configuration cache instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWaitHandle(CmsWaitHandle handle) Adds a wait handle to the list of wait handles.voidclear()Clears the cache.getName()Gets the cache instance name.getState()Gets the collection of cached formatters.voidInitializes the cache and installs the update task.voidThe method called by the scheduled update action to update the cache.protected I_CmsFormatterBeanreadFormatter(CmsUUID structureId) Reads a formatter given its structure id and returns it, or null if the formatter couldn't be read.voidreload()Reloads the formatter cache.voidremove(CmsPublishedResource pubRes) Removes a published resource from the cache.voidremove(CmsResource resource) Removes a resource from the cache.voidupdate(CmsPublishedResource pubRes) Updates the cache entry for the given published resource.voidupdate(CmsResource resource) Updates the cache entry for the given resource.voidWaits 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_CmsGlobalConfigurationCacheClears the cache.- Specified by:
clearin 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_CmsGlobalConfigurationCacheRemoves a published resource from the cache.- Specified by:
removein interfaceI_CmsGlobalConfigurationCache- Parameters:
pubRes- the published resource- See Also:
-
remove
Description copied from interface:I_CmsGlobalConfigurationCacheRemoves a resource from the cache.- Specified by:
removein interfaceI_CmsGlobalConfigurationCache- Parameters:
resource- the resource to remove- See Also:
-
update
Description copied from interface:I_CmsGlobalConfigurationCacheUpdates 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:
updatein interfaceI_CmsGlobalConfigurationCache- Parameters:
pubRes- a published resource- See Also:
-
update
Description copied from interface:I_CmsGlobalConfigurationCacheUpdates 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:
updatein 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
-