org.apache.cocoon.configuration
Class MutableSettings

java.lang.Object
  extended byorg.apache.cocoon.configuration.MutableSettings
All Implemented Interfaces:
Settings

public class MutableSettings
extends Object
implements Settings

This is an implementation of the Settings object. The value can either be set using the various setter methods or through properties (configure(Properties). The object can be set to read-only using makeReadOnly(). From that on the object is immutable and can't be changed anymore.

Since:
1.0
Version:
$Id: MutableSettings.java 587750 2007-10-24 02:35:22Z vgritsenko $

Field Summary
protected  String cacheDirectory
          This parameter allows to specify where Cocoon should create its page and other objects cache.
protected  long configurationReloadDelay
          Delay between reload checks for the configuration.
protected  String containerEncoding
          The container encoding.
protected  long creationTime
          The time the cocoon instance was created.
protected  String formEncoding
          Set form encoding.
protected static String KEYPREFIX
          Prefix for properties.
protected  List loadClasses
          This parameter is used to list classes that should be loaded at initialization time of the servlet.
protected  Settings parent
          The optional parent settings object.
protected  Properties properties
          The properties used to configure Cocoon.
protected  boolean readOnly
          Are we still mutable?
protected  boolean reloadingEnabled
          Allow reinstantiating (reloading) of the cocoon instance.
protected  String runningMode
          Running mode.
protected  String workDirectory
          This parameter allows to specify where Cocoon should put it's working files.
 
Fields inherited from interface org.apache.cocoon.configuration.Settings
KEY_CACHE_DIRECTORY, KEY_CONTAINER_ENCODING, KEY_FORM_ENCODING, KEY_LOAD_CLASSES, KEY_RELOAD_DELAY, KEY_RELOADING, KEY_WORK_DIRECTORY, PROPERTY_USER_SETTINGS, ROLE
 
Constructor Summary
MutableSettings(Settings parent)
          Create a new child settings object.
MutableSettings(String mode)
          Create a new settings object.
 
Method Summary
 void addToLoadClasses(String className)
           
protected  void checkSubSetting()
          check if this configuration is tried to be set for a sub settings object.
protected  void checkWriteable()
          check if this configuration is writeable.
 void configure(Properties props)
          Fill from a properties object
 String getCacheDirectory()
           
 String getContainerEncoding()
           
 long getCreationTime()
          The creation time of the current settings instance.
 String getFormEncoding()
           
 List getLoadClasses()
           
 String getProperty(String name)
          Get the value of a property.
 String getProperty(String key, String defaultValue)
          Get the value of a property.
 List getPropertyNames()
          Return all available property names.
 List getPropertyNames(String keyPrefix)
          Return all available property names starting with the prefix.
 long getReloadDelay(String type)
          This method can be used by components to get the configured delay period inbetween checks.
 String getRunningMode()
          Return the current running mode.
 String getWorkDirectory()
           
 boolean isReloadingEnabled(String type)
          This method can be used by components to query if they are configured to check for reloading.
 void makeReadOnly()
          Mark this object as read-only.
 void setCacheDirectory(String cacheDirectory)
           
 void setConfigurationReloadDelay(long configurationReloadDelay)
           
 void setContainerEncoding(String value)
          Set the container encoding.
 void setCreationTime(long value)
          Set the creation time of the current cocoon instance.
 void setFormEncoding(String formEncoding)
           
 void setReloadingEnabled(boolean allowReload)
           
 void setWorkDirectory(String workDirectory)
           
 String toString()
           
protected  String toString(List a)
          Helper method to make a string out of a list of objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

readOnly

protected boolean readOnly
Are we still mutable?


KEYPREFIX

protected static final String KEYPREFIX
Prefix for properties.

See Also:
Constant Field Values

properties

protected final Properties properties
The properties used to configure Cocoon.


reloadingEnabled

protected boolean reloadingEnabled
Allow reinstantiating (reloading) of the cocoon instance. If this is set to "yes" or "true", a new cocoon instance can be created using the request parameter "cocoon-reload". It also enables that Cocoon is reloaded when cocoon.xconf changes. Default is no for security reasons.


loadClasses

protected final List loadClasses
This parameter is used to list classes that should be loaded at initialization time of the servlet. For example, JDBC Drivers used need to be named here. Additional entries may be inserted here during build depending on your build properties.


cacheDirectory

protected String cacheDirectory
This parameter allows to specify where Cocoon should create its page and other objects cache. The path specified can be either absolute or relative to the context path of the servlet. On windows platform, absolute directory must start with volume: C:\Path\To\Cache\Directory.


workDirectory

protected String workDirectory
This parameter allows to specify where Cocoon should put it's working files. The path specified is either absolute or relative to the context path of the Cocoon servlet. On windows platform, absolute directory must start with volume: C:\Path\To\Work\Directory.


formEncoding

protected String formEncoding
Set form encoding. This will be the character set used to decode request parameters. If not set the ISO-8859-1 encoding will be assumed.


configurationReloadDelay

protected long configurationReloadDelay
Delay between reload checks for the configuration.


creationTime

protected long creationTime
The time the cocoon instance was created.


containerEncoding

protected String containerEncoding
The container encoding.

See Also:
Settings.KEY_CONTAINER_ENCODING

parent

protected Settings parent
The optional parent settings object.


runningMode

protected final String runningMode
Running mode.

Constructor Detail

MutableSettings

public MutableSettings(String mode)
Create a new settings object.


MutableSettings

public MutableSettings(Settings parent)
Create a new child settings object.

Parameters:
parent - The parent settings object.
Method Detail

configure

public void configure(Properties props)
Fill from a properties object


isReloadingEnabled

public boolean isReloadingEnabled(String type)
Description copied from interface: Settings
This method can be used by components to query if they are configured to check for reloading.

Specified by:
isReloadingEnabled in interface Settings
Parameters:
type - The type of the component that wants to check for reload.
Returns:
Returns if reloading is enabled for this component.
See Also:
Settings.isReloadingEnabled(java.lang.String)

getCacheDirectory

public String getCacheDirectory()
Specified by:
getCacheDirectory in interface Settings
Returns:
Returns the cacheDirectory.
See Also:
Settings.getCacheDirectory()

getFormEncoding

public String getFormEncoding()
Specified by:
getFormEncoding in interface Settings
Returns:
Returns the formEncoding.
See Also:
Settings.getFormEncoding()

getContainerEncoding

public String getContainerEncoding()
Specified by:
getContainerEncoding in interface Settings
Returns:
Returns the container encoding
See Also:
Settings.getContainerEncoding()

setContainerEncoding

public void setContainerEncoding(String value)
Set the container encoding.

Parameters:
value - The new encoding value.

getLoadClasses

public List getLoadClasses()
Specified by:
getLoadClasses in interface Settings
Returns:
Returns the loadClasses.
See Also:
Settings.getLoadClasses()

getWorkDirectory

public String getWorkDirectory()
Specified by:
getWorkDirectory in interface Settings
Returns:
Returns the workDirectory.
See Also:
Settings.getWorkDirectory()

getReloadDelay

public long getReloadDelay(String type)
Description copied from interface: Settings
This method can be used by components to get the configured delay period inbetween checks.

Specified by:
getReloadDelay in interface Settings
Parameters:
type - The type of the component that wants to check for reload.
Returns:
Returns the delay inbetween checks in milliseconds.
See Also:
Settings.getReloadDelay(java.lang.String)

getProperty

public String getProperty(String name)
Description copied from interface: Settings
Get the value of a property.

Specified by:
getProperty in interface Settings
Parameters:
name - The name of the property.
Returns:
The value of the property or null.
See Also:
Settings.getProperty(java.lang.String)

getProperty

public String getProperty(String key,
                          String defaultValue)
Description copied from interface: Settings
Get the value of a property.

Specified by:
getProperty in interface Settings
Parameters:
key - The name of the property.
defaultValue - The value returned if the property is not available.
Returns:
The value of the property or if the property cannot be found the default value.
See Also:
Settings.getProperty(java.lang.String, java.lang.String)

toString

public String toString()
See Also:
Object.toString()

toString

protected String toString(List a)
Helper method to make a string out of a list of objects.


setReloadingEnabled

public void setReloadingEnabled(boolean allowReload)
Parameters:
allowReload - The allowReload to set.

setCacheDirectory

public void setCacheDirectory(String cacheDirectory)
Parameters:
cacheDirectory - The cacheDirectory to set.

setFormEncoding

public void setFormEncoding(String formEncoding)
Parameters:
formEncoding - The formEncoding to set.

addToLoadClasses

public void addToLoadClasses(String className)
Parameters:
className - The loadClasses to set.

setWorkDirectory

public void setWorkDirectory(String workDirectory)
Parameters:
workDirectory - The workDirectory to set.

setConfigurationReloadDelay

public void setConfigurationReloadDelay(long configurationReloadDelay)
Parameters:
configurationReloadDelay - The configurationReloadDelay to set.

makeReadOnly

public void makeReadOnly()
Mark this object as read-only.


checkWriteable

protected final void checkWriteable()
                             throws IllegalStateException
check if this configuration is writeable.

Throws:
IllegalStateException - if this setting is read-only

checkSubSetting

protected final void checkSubSetting()
                              throws IllegalStateException
check if this configuration is tried to be set for a sub settings object.

Throws:
IllegalStateException - if this setting is a sub setting

getCreationTime

public long getCreationTime()
Description copied from interface: Settings
The creation time of the current settings instance.

Specified by:
getCreationTime in interface Settings
Returns:
The creation time.
See Also:
Settings.getCreationTime()

setCreationTime

public void setCreationTime(long value)
Set the creation time of the current cocoon instance.


getPropertyNames

public List getPropertyNames(String keyPrefix)
Description copied from interface: Settings
Return all available property names starting with the prefix.

Specified by:
getPropertyNames in interface Settings
Parameters:
keyPrefix - The prefix each property name must have.
Returns:
A list of property names (including the prefix) or an empty list.
See Also:
Settings.getPropertyNames(java.lang.String)

getPropertyNames

public List getPropertyNames()
Description copied from interface: Settings
Return all available property names.

Specified by:
getPropertyNames in interface Settings
Returns:
A list of all property names or an empty list.
See Also:
Settings.getPropertyNames()

getRunningMode

public String getRunningMode()
Description copied from interface: Settings
Return the current running mode.

Specified by:
getRunningMode in interface Settings
Returns:
The current running mode.
See Also:
Settings.getRunningMode()


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.