Package org.ametys.web.cache.pageelement
Class PageElementCache
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.web.cache.pageelement.PageElementCache
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Disposable
,Initializable
,Component
,Configurable
,Contextualizable
,Serviceable
public class PageElementCache
extends AbstractLogEnabled
implements Component, Contextualizable, Disposable, Serviceable, Initializable, PluginAware, Configurable
Cache the page elements renderings.
This class handles several caches, one per site and per JCR workspace.
This class handles several caches, one per site and per JCR workspace.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all stored data.void
Removes all data associated with a JCR workspace and a site.void
Removes all data associated with a JCR workspace, a site and a given element type.void
configure
(Configuration configuration) void
contextualize
(Context context) void
dispose()
getElementCache
(String workspace, String site, String pageElementType) Returns all cached data for a given InputData, or null if none.getPageElement
(String workspace, String site, String pageElementType, String elementId, String subElementId, RenderingContext renderingContext) Returns the data in the cache, or null if none.getPageElement
(String workspace, String site, String pageElementType, String elementId, RenderingContext renderingContext) Returns the data in the cache, or null if none.getPageElementTypes
(String workspace, String site) Returns all stored element types, or null if none.void
protected boolean
Test if the cache is enabled.void
removeItem
(String workspace, String site, String pageElementType, String elementId) Removes a single item from the cache.void
service
(ServiceManager manager) void
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.void
storePageElement
(String workspace, String site, String pageElementType, String elementId, String subElementId, RenderingContext renderingContext, SaxBuffer content) Add a content in the cache.void
storePageElement
(String workspace, String site, String pageElementType, String elementId, RenderingContext renderingContext, SaxBuffer content) Add a content in the cache.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon role. -
DISABLE_PE_CACHE_ATTRIBUTE
"Disable page element cache" request attribute.- See Also:
-
-
Constructor Details
-
PageElementCache
public PageElementCache()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
storePageElement
public void storePageElement(String workspace, String site, String pageElementType, String elementId, RenderingContext renderingContext, SaxBuffer content) Add a content in the cache.- Parameters:
workspace
- the current JCR workspace.site
- the current site.pageElementType
- the page element type.elementId
- the element id (page id or zoneItem id).renderingContext
- the current rendering context.content
- the actual content.
-
storePageElement
public void storePageElement(String workspace, String site, String pageElementType, String elementId, String subElementId, RenderingContext renderingContext, SaxBuffer content) Add a content in the cache.- Parameters:
workspace
- the current JCR workspace.site
- the current site.pageElementType
- the page element type.elementId
- the element id (page id or zoneItem id).subElementId
- the sub-element id (page id, in case the element id is a zoneItem id).renderingContext
- the current rendering context.content
- the actual content.
-
getPageElement
public SaxBuffer getPageElement(String workspace, String site, String pageElementType, String elementId, RenderingContext renderingContext) Returns the data in the cache, or null if none.- Parameters:
workspace
- the current JCR workspace.site
- the current site.pageElementType
- the element type.elementId
- the element id (page id or zoneItem id).renderingContext
- the current rendering context.- Returns:
- the stored content.
-
getPageElement
public SaxBuffer getPageElement(String workspace, String site, String pageElementType, String elementId, String subElementId, RenderingContext renderingContext) Returns the data in the cache, or null if none.- Parameters:
workspace
- the current JCR workspace.site
- the current site.pageElementType
- the element type.elementId
- the element id (page id or zoneItem id).subElementId
- the sub-element id (page id, in case the element id is a zoneItem id).renderingContext
- the current rendering context.- Returns:
- the stored content.
-
getPageElementTypes
Returns all stored element types, or null if none.- Parameters:
workspace
- the current JCR workspace.site
- the current site.- Returns:
- all stored element types.
-
getElementCache
Returns all cached data for a given InputData, or null if none.- Parameters:
workspace
- the current JCR workspace.site
- the current site.pageElementType
- the element type.- Returns:
- the stored content.
-
removeItem
Removes a single item from the cache.- Parameters:
workspace
- the target JCR workspace or null to remove from all workspaces.site
- the target site.pageElementType
- the element type.elementId
- the element id.
-
clear
Removes all stored data. -
clear
Removes all data associated with a JCR workspace and a site.- Parameters:
workspace
- the current JCR workspace. If null, means all workspaces.site
- the current site.
-
clear
Removes all data associated with a JCR workspace, a site and a given element type.- Parameters:
workspace
- the current JCR workspace.site
- the current site.pageElementType
- the element type.
-
dispose
- Specified by:
dispose
in interfaceDisposable
-
isEnabled
Test if the cache is enabled.- Returns:
- true if the cache is enabled, false otherwise.
-