public class PageElementCache extends AbstractLogEnabled implements Component, Contextualizable, Disposable
| Modifier and Type | Field and Description | 
|---|---|
private Map<String,Map<String,Map<String,Map<String,Map<String,Map<RenderingContext,SaxBuffer>>>>>> | 
_cache  | 
private Context | 
_context  | 
private Map<String,Map<String,Map<String,AtomicInteger>>> | 
_currentHitCount  | 
private Map<String,Map<String,Map<String,AtomicInteger>>> | 
_hitCount  | 
private Map<String,Map<String,Map<String,AtomicInteger>>> | 
_missCount  | 
static String | 
DISABLE_PE_CACHE_ATTRIBUTE
"Disable page element cache" request attribute. 
 | 
static String | 
ROLE
Avalon role. 
 | 
| Constructor and Description | 
|---|
PageElementCache()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
clear()
Removes all stored data. 
 | 
void | 
clear(String workspace,
     String site)
Removes all data associated with a JCR workspace and a site. 
 | 
void | 
clear(String workspace,
     String site,
     String pageElementType)
Removes all data associated with a JCR workspace, a site and a given element type. 
 | 
void | 
contextualize(Context context)  | 
void | 
dispose()  | 
protected int | 
getCount(Map<String,Map<String,Map<String,AtomicInteger>>> countMap,
        String workspace,
        String siteName,
        String pageElementType)
Get a hit or miss count for a workspace, site and page element type. 
 | 
Map<String,Map<String,Map<RenderingContext,SaxBuffer>>> | 
getElementCache(String workspace,
               String site,
               String pageElementType)
Returns all cached data for a given InputData, or null if none. 
 | 
SaxBuffer | 
getPageElement(String workspace,
              String site,
              String pageElementType,
              String elementId,
              RenderingContext renderingContext)
Returns the data in the cache, or null if none. 
 | 
SaxBuffer | 
getPageElement(String workspace,
              String site,
              String pageElementType,
              String elementId,
              String subElementId,
              RenderingContext renderingContext)
Returns the data in the cache, or null if none. 
 | 
Set<String> | 
getPageElementTypes(String workspace,
                   String site)
Returns all stored element types, or null if none. 
 | 
protected void | 
incrementCount(Map<String,Map<String,Map<String,AtomicInteger>>> countMap,
              String workspace,
              String siteName,
              String pageElementType)
Add a hit count for a workspace, site and page element type. 
 | 
protected boolean | 
isEnabled()
Test if the cache is enabled. 
 | 
protected void | 
logAndResetHitCount()
Reset the hit count after logging the old value. 
 | 
protected void | 
logAndResetHitCount(String workspace,
                   String siteName)
Reset the hit count after logging the old value. 
 | 
protected void | 
logAndResetHitCount(String workspace,
                   String siteName,
                   String pageElementType)
Reset the hit count after logging the old value. 
 | 
protected void | 
logAndResetHitCount(String workspace,
                   String siteName,
                   String pageElementType,
                   AtomicInteger hitCount)
Reset the hit count after logging the old value. 
 | 
protected void | 
logFullHitCount(String workspace,
               String siteName,
               String pageElementType)
Log the full hit and miss count for a given workspace, site and page element type. 
 | 
void | 
removeItem(String workspace,
          String site,
          String pageElementType,
          String elementId)
Removes a single item from the cache. 
 | 
void | 
storePageElement(String workspace,
                String site,
                String pageElementType,
                String elementId,
                RenderingContext renderingContext,
                SaxBuffer content)
Add a content in the cache. 
 | 
void | 
storePageElement(String workspace,
                String site,
                String pageElementType,
                String elementId,
                String subElementId,
                RenderingContext renderingContext,
                SaxBuffer content)
Add a content in the cache. 
 | 
enableLogging, getLogger, setupLogger, setupLogger, setupLoggerpublic static final String DISABLE_PE_CACHE_ATTRIBUTE
private Map<String,Map<String,Map<String,Map<String,Map<String,Map<RenderingContext,SaxBuffer>>>>>> _cache
private Map<String,Map<String,Map<String,AtomicInteger>>> _currentHitCount
private Map<String,Map<String,Map<String,AtomicInteger>>> _missCount
public PageElementCache()
public void contextualize(Context context) throws ContextException
contextualize in interface ContextualizableContextExceptionpublic void storePageElement(String workspace, String site, String pageElementType, String elementId, RenderingContext renderingContext, SaxBuffer content)
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.public void storePageElement(String workspace, String site, String pageElementType, String elementId, String subElementId, RenderingContext renderingContext, SaxBuffer content)
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.public SaxBuffer getPageElement(String workspace, String site, String pageElementType, String elementId, RenderingContext renderingContext)
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.public SaxBuffer getPageElement(String workspace, String site, String pageElementType, String elementId, String subElementId, RenderingContext renderingContext)
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.public Set<String> getPageElementTypes(String workspace, String site)
workspace - the current JCR workspace.site - the current site.public Map<String,Map<String,Map<RenderingContext,SaxBuffer>>> getElementCache(String workspace, String site, String pageElementType)
workspace - the current JCR workspace.site - the current site.pageElementType - the element type.public void removeItem(String workspace, String site, String pageElementType, String elementId)
workspace - the target JCR workspace or null to remove from all workspaces.site - the target site.pageElementType - the element type.elementId - the element id.public void clear()
public void clear(String workspace, String site)
workspace - the current JCR workspace. If null, means all workspaces.site - the current site.public void clear(String workspace, String site, String pageElementType)
workspace - the current JCR workspace.site - the current site.pageElementType - the element type.public void dispose()
dispose in interface Disposableprotected boolean isEnabled()
protected void incrementCount(Map<String,Map<String,Map<String,AtomicInteger>>> countMap, String workspace, String siteName, String pageElementType)
countMap - the map to fill.workspace - the workspace.siteName - the site name.pageElementType - the page element type.protected int getCount(Map<String,Map<String,Map<String,AtomicInteger>>> countMap, String workspace, String siteName, String pageElementType)
countMap - the count map.workspace - the workspace.siteName - the site name.pageElementType - the page element type.protected void logAndResetHitCount()
protected void logAndResetHitCount(String workspace, String siteName)
workspace - the workspace.siteName - the site name.protected void logAndResetHitCount(String workspace, String siteName, String pageElementType)
workspace - the workspace.siteName - the site name.pageElementType - the page element type.protected void logAndResetHitCount(String workspace, String siteName, String pageElementType, AtomicInteger hitCount)
workspace - the workspace.siteName - the site name.pageElementType - the page element type.hitCount - the old hit count.protected void logFullHitCount(String workspace, String siteName, String pageElementType)
workspace - the workspace.siteName - the site name.pageElementType - the page element type.