com.opensymphony.oscache.base
Class Config

java.lang.Object
  extended bycom.opensymphony.oscache.base.Config
All Implemented Interfaces:
java.io.Serializable

public class Config
extends java.lang.Object
implements java.io.Serializable

Responsible for holding the Cache configuration properties. If the default constructor is used, this class will load the properties from the cache.configuration.

Version:
$Revision: 1.2 $
Author:
Fabian Crabus
See Also:
Serialized Form

Constructor Summary
Config()
          Create an OSCache Config that loads properties from oscache.properties.
Config(java.util.Properties p)
          Create an OSCache configuration with the specified properties.
 
Method Summary
 java.lang.Object get(java.lang.Object key)
           
 java.util.Properties getProperties()
          Retrieves all of the configuration properties.
 java.lang.String getProperty(java.lang.String key)
          Retrieve the value of the named configuration property.
 void set(java.lang.Object key, java.lang.Object value)
          Sets a configuration property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Config

public Config()
Create an OSCache Config that loads properties from oscache.properties. The file must be present in the root of OSCache's classpath. If the file cannot be loaded, an error will be logged and the configuration will remain empty.


Config

public Config(java.util.Properties p)
Create an OSCache configuration with the specified properties. Note that it is the responsibility of the caller to provide valid properties as no error checking is done to ensure that required keys are present. If you're unsure of what keys should be present, have a look at a sample oscache.properties file.

Parameters:
p - The properties to use for this configuration. If null, then the default properties are loaded from the oscache.properties file.
Method Detail

getProperty

public java.lang.String getProperty(java.lang.String key)
Retrieve the value of the named configuration property. If the property cannot be found this method will return null.

Parameters:
key - The name of the property.
Returns:
The property value, or null if the value could not be found.
Throws:
java.lang.IllegalArgumentException - if the supplied key is null.

getProperties

public java.util.Properties getProperties()
Retrieves all of the configuration properties. This property set should be treated as immutable.

Returns:
The configuration properties.

get

public java.lang.Object get(java.lang.Object key)

set

public void set(java.lang.Object key,
                java.lang.Object value)
Sets a configuration property.

Parameters:
key - The unique name for this property.
value - The value assigned to this property.
Throws:
java.lang.IllegalArgumentException - if the supplied key is null.

See www.opensymphony.com for more information.