org.osesb.configuration
Class SimpleCacheConfiguration

java.lang.Object
  extended by org.osesb.configuration.XMLConfiguration
      extended by org.osesb.configuration.SimpleCacheConfiguration

public class SimpleCacheConfiguration
extends XMLConfiguration

Parses a SimpleCache configuration content model in a XML configuration file and sets configurationProperties. Contains convenience methods for accessing SimpleCache properties.

Example SimpleCache configuration content model:

<simplecache-configuration>
      <!-- SimpleCacheEvictionScanner thread sleep interval -->
      <timeBetweenEvictionRunsSeconds>36000</timeBetweenEvictionRunsSeconds>
      <!-- The maximum number of cache entries -->
      <maxCacheSize>36000</maxCacheSize>
      <!-- The CacheEntry field that is used to sort CacheEntrys(s) in evict() -->
      <evictionStrategyField>lastAccessedTime</evictionStrategyField>
  </simplecache-configuration>
 

SimpleCache implementations use this configuration to instantiate SimpleCache objects. Some SimpleCache implementations are in the org.osesb.utilities.cache package.

The framework uses the following caches to cache objects retrieved from the XMLRepository:

A single SimpleCacheConfiguration for these caches is included in a project's XMLRepositoryConfiguration.

Since:
Version .9

Field Summary
 
Fields inherited from class org.osesb.configuration.XMLConfiguration
configFilePath, configurationProperties, constructedFromConfigFile, contentModelElement, ftpClientConfiguration, jaxrpcClientConfiguration, jdbcConfiguration, jmsClientConfiguration, log, rootConfigurationAttributes, smtpClientConfiguration, systemProperties, thisClassName
 
Constructor Summary
SimpleCacheConfiguration(org.w3c.dom.Element contentModelElement)
          Creates a new instance of SimpleCacheConfiguration given the content model Element.
SimpleCacheConfiguration(java.util.Properties configurationProperties)
          Creates a new instance of SimpleCacheConfiguration given the configuration Properties.
SimpleCacheConfiguration(java.lang.String configFile)
          Creates a new instance of SimpleCacheConfiguration given a XML configuration file.
SimpleCacheConfiguration(java.lang.String configFile, java.lang.String xpathExpression)
          Creates a new instance of SimpleCacheConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.
 
Method Summary
 java.lang.String getEvictionStrategyField()
          Returns the CacheEntry field that is used to sort CacheEntrys(s) in evict().
 int getMaxCacheSize()
          Return the maximum size of the cache
 long getTimeBetweenEvictionRunsSeconds()
          Return the number of seconds that the SimpleCacheEvictionScanner thread should sleep between "runs".
static void main(java.lang.String[] args)
          main() for testing and sandboxing.
 void setEvictionStrategyField(java.lang.String evictionStrategyField)
          Sets the CacheEntry field that is used to sort CacheEntrys(s) in evict().
 void setMaxCacheSize(int maxCacheSize)
          Set the maximum size of the cache.
 void setTimeBetweenEvictionRunsSeconds(long timeBetweenEvictionRunsSeconds)
          Set the number of seconds that the SimpleCacheEvictionScanner thread should sleep between "runs".
 
Methods inherited from class org.osesb.configuration.XMLConfiguration
checkXMLConfigurationClass, clear, doEncryptionInstructions, getBooleanConfigurationProperty, getBooleanRootConfigurationAttribute, getConfigFilePath, getConfigurationAttribute, getConfigurationAttributes, getConfigurationElement, getConfigurationElements, getConfigurationProperties, getConfigurationProperty, getConfigurationProperty, getContentModelElement, getDebugFlag, getDocument, getEncryptionInstructions, getFTPClientConfiguration, getIntConfigurationProperty, getIntRootConfigurationAttribute, getJAXRPCClientConfiguration, getJDBCConfiguration, getJMSClientConfiguration, getLongConfigurationProperty, getLongRootConfigurationAttribute, getName, getRootConfigurationAttribute, getRootConfigurationAttributes, getSMTPClientConfiguration, getSystemProperties, getSystemProperty, isConfigurationElementEmpty, loadConfiguration, loadExternalConfiguration, loadFTPClientConfiguration, loadJAXRPCClientConfiguration, loadJDBCConfiguration, loadJMSClientConfiguration, loadPropertiesFromContentModel, loadSMTPClientConfiguration, loadSystemProperties, mergeConfigurationProperties, setConfigFilePath, setConfigurationProperty, setDebugFlag, setFTPClientConfiguration, setJAXRPCClientConfiguration, setJDBCConfiguration, setJMSClientConfiguration, setName, setRootConfigurationAttribute, setSMTPClientConfiguration, setSystemProperties, setSystemProperty, toString, writeConfigurationFile, writeConfigurationFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleCacheConfiguration

public SimpleCacheConfiguration(java.lang.String configFile)
                         throws java.lang.Exception
Creates a new instance of SimpleCacheConfiguration given a XML configuration file. The root element of the XML configuration file is the starting element for the configuration.

Parameters:
configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

SimpleCacheConfiguration

public SimpleCacheConfiguration(java.lang.String configFile,
                                java.lang.String xpathExpression)
                         throws java.lang.Exception
Creates a new instance of SimpleCacheConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.

An empty xpathExpression implies that the root element of the XML configuration file is the starting element for the configuration.

Parameters:
configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
xpathExpression - A XPath expression that evaluates to the element that marks the beginning of the configuration. If following the framework convention for SimpleCacheConfiguration(s), xpathExpression should have 'simplecache-configuration' as the last Element in the path.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

SimpleCacheConfiguration

public SimpleCacheConfiguration(org.w3c.dom.Element contentModelElement)
                         throws java.lang.Exception
Creates a new instance of SimpleCacheConfiguration given the content model Element.

Parameters:
contentModelElement - The top level Element for the for the configuration.
Throws:
java.lang.Exception - if there is a fatal error transversing the configuration content model enclosed by contentModelElement.

SimpleCacheConfiguration

public SimpleCacheConfiguration(java.util.Properties configurationProperties)
Creates a new instance of SimpleCacheConfiguration given the configuration Properties.

Parameters:
configurationProperties - Configuration name / value pairs as Properties.
Method Detail

getTimeBetweenEvictionRunsSeconds

public long getTimeBetweenEvictionRunsSeconds()
Return the number of seconds that the SimpleCacheEvictionScanner thread should sleep between "runs".

Returns:
the number of seconds that the SimpleCacheEvictionScanner thread should sleep between "runs".

setTimeBetweenEvictionRunsSeconds

public void setTimeBetweenEvictionRunsSeconds(long timeBetweenEvictionRunsSeconds)
Set the number of seconds that the SimpleCacheEvictionScanner thread should sleep between "runs".

Parameters:
timeBetweenEvictionRunsSeconds - The number of seconds that the SimpleCacheEvictionScanner thread should sleep between "runs".

getMaxCacheSize

public int getMaxCacheSize()
Return the maximum size of the cache

Returns:
the maximum size of the cache

setMaxCacheSize

public void setMaxCacheSize(int maxCacheSize)
Set the maximum size of the cache.

Parameters:
maxCacheSize - The maximum size of the cache.

getEvictionStrategyField

public java.lang.String getEvictionStrategyField()
Returns the CacheEntry field that is used to sort CacheEntrys(s) in evict().

Returns:
the CacheEntry field that is used to sort CacheEntrys(s) in evict().

setEvictionStrategyField

public void setEvictionStrategyField(java.lang.String evictionStrategyField)
Sets the CacheEntry field that is used to sort CacheEntrys(s) in evict().

Parameters:
evictionStrategyField - The CacheEntry field that is used to sort CacheEntrys(s) in evict().

main

public static void main(java.lang.String[] args)
main() for testing and sandboxing.

Parameters:
args - commandline arguments