com.opencms.template.cache
Class A_CmsElement

java.lang.Object
  |
  +--com.opencms.template.cache.A_CmsElement
All Implemented Interfaces:
I_CmsLogChannels
Direct Known Subclasses:
CmsElementDump, CmsElementXml, CmsMethodElement

public abstract class A_CmsElement
extends Object
implements I_CmsLogChannels

An instance of A_CmsElement represents an requestable Element in the OpenCms element cache area. It contains all informations to generate the content of this element. It also stores the variants of once generated content to speed up performance. It may point to other depending elements. Theses elements are called to generate their content on generation-time.

Author:
Andreas Schouten, Alexander Lucas

Field Summary
protected  A_CmsCacheDirectives m_cacheDirectives
          Cache directives of this element.
protected  String m_className
          The class-name of this element definition.
protected  CmsElementDefinitionCollection m_elementDefinitions
          All definitions declared in this element.
protected  boolean m_hasDepVariants
          indicates if this element may have a variant that has dependencies if such a element is deletet from elementcache the extern dependencies hashtable must be updated.
protected  String m_readAccessGroup
          The name of the group that can read this ressource.
protected  String m_templateName
          The template-name of this element definition.
protected  long m_timestamp
          Last time this element was generated.
 
Fields inherited from interface com.opencms.boot.I_CmsLogChannels
C_FLEX_CACHE, C_FLEX_LOADER, C_LOGGING, C_MODULE_CRITICAL, C_MODULE_DEBUG, C_MODULE_INFO, C_OPENCMS_CACHE, C_OPENCMS_CRITICAL, C_OPENCMS_CRONSCHEDULER, C_OPENCMS_DEBUG, C_OPENCMS_ELEMENTCACHE, C_OPENCMS_INFO, C_OPENCMS_INIT, C_OPENCMS_POOL, C_OPENCMS_STATICEXPORT, C_OPENCMS_STREAMING, C_PREPROCESSOR_IS_LOGGING
 
Constructor Summary
A_CmsElement()
           
 
Method Summary
 void addDefinition(CmsElementDefinition def)
          Adds a single definition to this element.
 Vector addVariant(Object key, CmsElementVariant variant)
          Adds a single variant to this element.
 void checkProxySettings(CmsObject cms, CmsCacheDirectives proxySettings, Hashtable parameters)
          checks the proxy public and the proxy private cache settings of this element and all subelements.
 void checkReadAccess(CmsObject cms)
          checks the read access.
 void clearVariantCache()
          Clears all variants.
 CmsElementDefinitionCollection getAllDefinitions()
          Returns a Vector with all ElementDefinitions
 Vector getAllVariantKeys()
           
 A_CmsCacheDirectives getCacheDirectives()
          Get cache directives for this element.
abstract  byte[] getContent(CmsElementCache elementCache, CmsObject cms, CmsElementDefinitionCollection efDefs, String elementName, Hashtable parameters, String methodParameter)
          Abstract method for getting the content of this element.
 CmsElementDefinition getElementDefinition(String name)
          Get the element definition for the sub-element with the given name
protected  I_CmsTemplate getTemplateClass(CmsObject cms, String classname)
          Get a template class from the template class manager.
 CmsElementVariant getVariant(Object key)
          Get a variant from the vatiant cache
 boolean hasDependenciesVariants()
          says if the extern dependenciescache has to be updated when this element is deleted.
protected  void init(String className, String templateName, String readAccessGroup, A_CmsCacheDirectives cd, CmsElementDefinitionCollection defs, int variantCachesize)
          Initializer for building an element with the given element definitions.
protected  void init(String className, String templateName, String readAccessGroup, A_CmsCacheDirectives cd, int variantCachesize)
          Initializer for an element with the given class and template name.
 void removeVariant(Object key)
           
 byte[] resolveVariant(CmsObject cms, CmsElementVariant variant, CmsElementCache elementCache, CmsElementDefinitionCollection elDefs, Hashtable parameters)
          Resolve given variant of this element and get content of all sub elements.
 void thisElementHasDepVariants()
          indicates this element critical for delete.
 String toString()
          Get a string representation of this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_className

protected String m_className
The class-name of this element definition.


m_templateName

protected String m_templateName
The template-name of this element definition.


m_cacheDirectives

protected A_CmsCacheDirectives m_cacheDirectives
Cache directives of this element.


m_readAccessGroup

protected String m_readAccessGroup
The name of the group that can read this ressource.


m_timestamp

protected long m_timestamp
Last time this element was generated.(used for CacheDirectives timeout)


m_elementDefinitions

protected CmsElementDefinitionCollection m_elementDefinitions
All definitions declared in this element.


m_hasDepVariants

protected boolean m_hasDepVariants
indicates if this element may have a variant that has dependencies if such a element is deletet from elementcache the extern dependencies hashtable must be updated.

Constructor Detail

A_CmsElement

public A_CmsElement()
Method Detail

init

protected void init(String className,
                    String templateName,
                    String readAccessGroup,
                    A_CmsCacheDirectives cd,
                    int variantCachesize)
Initializer for an element with the given class and template name.


init

protected void init(String className,
                    String templateName,
                    String readAccessGroup,
                    A_CmsCacheDirectives cd,
                    CmsElementDefinitionCollection defs,
                    int variantCachesize)
Initializer for building an element with the given element definitions.

Parameters:
className - the classname of this element-definition.
readAccessGroup - The group that may read the element.
cd - Cache directives for this element
defs - Vector with ElementDefinitions for this element.
variantCachesize - The size of the variant cache.

addDefinition

public void addDefinition(CmsElementDefinition def)
Adds a single definition to this element.

Parameters:
def - - the ElementDefinition to add.

addVariant

public Vector addVariant(Object key,
                         CmsElementVariant variant)
Adds a single variant to this element.

Returns:
a CmsElementVariant of dependencies that must be deleted from extern store for this element

removeVariant

public void removeVariant(Object key)

checkReadAccess

public void checkReadAccess(CmsObject cms)
                     throws CmsException
checks the read access.

Parameters:
cms - The cms Object for reading groups.
Throws:
CmsException - if no read access.

clearVariantCache

public void clearVariantCache()
Clears all variants. Used for TimeCritical elements.


getAllVariantKeys

public Vector getAllVariantKeys()

getVariant

public CmsElementVariant getVariant(Object key)
Get a variant from the vatiant cache

Parameters:
key - Key of the ElementVariant.
Returns:
Cached CmsElementVariant object

hasDependenciesVariants

public boolean hasDependenciesVariants()
says if the extern dependenciescache has to be updated when this element is deleted.


thisElementHasDepVariants

public void thisElementHasDepVariants()
indicates this element critical for delete.


getAllDefinitions

public CmsElementDefinitionCollection getAllDefinitions()
Returns a Vector with all ElementDefinitions

Returns:
a Vector with all ElementDefinitions.

getElementDefinition

public CmsElementDefinition getElementDefinition(String name)
Get the element definition for the sub-element with the given name

Parameters:
name - Name of the sub-element that should be looked up
Returns:
Element definition of name

getCacheDirectives

public A_CmsCacheDirectives getCacheDirectives()
Get cache directives for this element.

Returns:
cache directives.

checkProxySettings

public void checkProxySettings(CmsObject cms,
                               CmsCacheDirectives proxySettings,
                               Hashtable parameters)
                        throws CmsException
checks the proxy public and the proxy private cache settings of this element and all subelements.

Parameters:
cms - the cms object.
proxySettings - The CacheDirectives to merge the own CacheDriectives with.
parameters - A Hashtable with the parameters.
CmsException

getContent

public abstract byte[] getContent(CmsElementCache elementCache,
                                  CmsObject cms,
                                  CmsElementDefinitionCollection efDefs,
                                  String elementName,
                                  Hashtable parameters,
                                  String methodParameter)
                           throws CmsException
Abstract method for getting the content of this element. Element classes may have different implementations for getting the contents. Common tasks of all implementations are checking the variant cache and creating the variant if required.

Parameters:
elementCache - Entry point for the element cache
cms - CmsObject for accessing system resources
parameters - All parameters of this request
Returns:
Byte array with the processed content of this element.
Throws:
CmsException

getTemplateClass

protected I_CmsTemplate getTemplateClass(CmsObject cms,
                                         String classname)
                                  throws CmsException
Get a template class from the template class manager.

Parameters:
cms - CmsObject for accessing system resources.
classname - Name of the requested class.
Throws:
CmsException - if the loaded class is no OpenCms template class

resolveVariant

public byte[] resolveVariant(CmsObject cms,
                             CmsElementVariant variant,
                             CmsElementCache elementCache,
                             CmsElementDefinitionCollection elDefs,
                             Hashtable parameters)
                      throws CmsException
Resolve given variant of this element and get content of all sub elements.

Parameters:
cms - CmsObject for accessing system resources
variant - Variant that should be resolved
elementCache - Entry point for element cache
elDefs - Definitions for all subelements
parameters - All parameters of this request
Returns:
Byte array with processed element content
Throws:
CmsException - if resolving fails.

toString

public String toString()
Get a string representation of this element.

Overrides:
toString in class Object
Returns:
String representation.