Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.opencms.flex.cache
Class CmsFlexCacheKey  view CmsFlexCacheKey download CmsFlexCacheKey.java

java.lang.Object
  extended bycom.opencms.flex.cache.CmsFlexCacheKey

public class CmsFlexCacheKey
extends java.lang.Object

Implements the CmsFlexCacheKey, which is a key used to describe the caching behaviour of a specific resource.

It has a lot of "public" variables (which isn't good style, I know) to avoid method calling overhead (a cache is about speed, isn't it :).

Version:
$Revision: 1.7.2.1 $

Field Summary
private  java.util.List cacheCmds
          The list of keywords of the Flex cache language
private static boolean DEBUG
          Debugging flag
 int m_always
          Cache key variable: Determines if this resource can be cached alwys, never or under certain conditions.
 java.util.Set m_groups
          Cache key variable: List of groups
private  boolean m_isRequest
          Flag used to determine if this key is from a request or not
 java.util.Set m_noparams
          Cache key variable: List of "blocking" parameters
 java.util.Map m_params
          Cache key variable: List of parameters
private  boolean m_parseError
          Flag raised in case a key parse error occured
 java.util.Set m_ports
          Cache key variable: The request TCP/IP port
 boolean m_publish
          Cache key variable: Determines if the resource sould be always cleared at publish time
 java.util.Set m_schemes
          Cache key variable: Distinguishes request schemes (http, https etc.)
 long m_timeout
          Cache key variable: Timeout of the resource
 java.lang.String m_uri
          Cache key variable: The uri of the original request
 int m_user
          Cache key variable: The user id
 java.lang.String Resource
          The OpenCms resource that this key is used for.
 java.lang.String Variation
          The cache behaviour description for the resource.
 
Constructor Summary
CmsFlexCacheKey(javax.servlet.ServletRequest request, java.lang.String target, boolean online)
          This constructor is used when building a cache key from a request.
CmsFlexCacheKey(java.lang.String target, java.lang.String cacheDirectives, boolean online)
          This constructor is used when building a cache key from set of cache directives.
 
Method Summary
static java.lang.String getKeyName(java.lang.String name, boolean online)
          Calculates the cache key name that is used as key in the first level of the FlexCache.
 boolean hadParseError()
          This flag is used to indicate that a parse error had occured, which can happen if the cache directives String passed to the constructor using the response is not build according to the Flex cache language syntax.
 java.lang.String matchRequestKey(CmsFlexCacheKey key)
          Compares this key to the other key passed as parameter, from comparing the two keys, a variation String is constructed.
private  void parseFlexKey(java.lang.String key)
          Parse a String in the Flex cache language and construct the key data structure from this.
private  java.util.Map parseValueMap(java.lang.String value)
          A helper method for the parsing process which parses Strings like groups=(a, b, c).
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Resource

public java.lang.String Resource
The OpenCms resource that this key is used for.


Variation

public java.lang.String Variation
The cache behaviour description for the resource.


m_always

public int m_always
Cache key variable: Determines if this resource can be cached alwys, never or under certain conditions. -1 = never, 0=check, 1=always


m_uri

public java.lang.String m_uri
Cache key variable: The uri of the original request


m_user

public int m_user
Cache key variable: The user id


m_groups

public java.util.Set m_groups
Cache key variable: List of groups


m_params

public java.util.Map m_params
Cache key variable: List of parameters


m_noparams

public java.util.Set m_noparams
Cache key variable: List of "blocking" parameters


m_timeout

public long m_timeout
Cache key variable: Timeout of the resource


m_publish

public boolean m_publish
Cache key variable: Determines if the resource sould be always cleared at publish time


m_schemes

public java.util.Set m_schemes
Cache key variable: Distinguishes request schemes (http, https etc.)


m_ports

public java.util.Set m_ports
Cache key variable: The request TCP/IP port


cacheCmds

private java.util.List cacheCmds
The list of keywords of the Flex cache language


m_isRequest

private boolean m_isRequest
Flag used to determine if this key is from a request or not


m_parseError

private boolean m_parseError
Flag raised in case a key parse error occured


DEBUG

private static final boolean DEBUG
Debugging flag

See Also:
Constant Field Values
Constructor Detail

CmsFlexCacheKey

public CmsFlexCacheKey(javax.servlet.ServletRequest request,
                       java.lang.String target,
                       boolean online)
This constructor is used when building a cache key from a request.

The request contains several data items that are neccessary to construct the output. These items are e.g. the Query-String, the requested resource, the current time etc. etc. All required items are saved in the constructed cache - key.


CmsFlexCacheKey

public CmsFlexCacheKey(java.lang.String target,
                       java.lang.String cacheDirectives,
                       boolean online)
This constructor is used when building a cache key from set of cache directives.

These directives are attached to the properties of the requested resource on a property called "cache". The value of this poperty that is passed in this constructor as "cacheDirectives" is parsed to build the keys data structure.

In case a parsing error occures, the value of this key is set to "cache=never", and the hadParseError() flag is set to true. This is done to ensure that a valid key is always constructed with the constructor.

Method Detail

getKeyName

public static java.lang.String getKeyName(java.lang.String name,
                                          boolean online)
Calculates the cache key name that is used as key in the first level of the FlexCache.


hadParseError

public boolean hadParseError()
This flag is used to indicate that a parse error had occured, which can happen if the cache directives String passed to the constructor using the response is not build according to the Flex cache language syntax.


matchRequestKey

public java.lang.String matchRequestKey(CmsFlexCacheKey key)
Compares this key to the other key passed as parameter, from comparing the two keys, a variation String is constructed.

This method is the "heart" of the key matching process.

The assumtion is that this key should be the one constructed for the response, while the parameter key should have been constructed from the request.

A short example how this works: If the resource key is "cache=groups" and the request is done from a guest user (which always belongs to the default group "guests"), the constructed variation will be "groups=(guests)".


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


parseFlexKey

private void parseFlexKey(java.lang.String key)
Parse a String in the Flex cache language and construct the key data structure from this.


parseValueMap

private java.util.Map parseValueMap(java.lang.String value)
A helper method for the parsing process which parses Strings like groups=(a, b, c).