org.apache.struts.config
Class BaseConfig

java.lang.Object
  extended by org.apache.struts.config.BaseConfig
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ActionConfig, ControllerConfig, ExceptionConfig, FormBeanConfig, FormPropertyConfig, ForwardConfig, MessageResourcesConfig, ModuleConfigImpl

public abstract class BaseConfig
extends Object
implements Serializable

A abstract base class for all config classes. Provide basic support for arbitrary properties

Since:
Struts 1.3
See Also:
Serialized Form

Field Summary
protected  boolean configured
          Indicates if configuration of this component been completed.
 
Constructor Summary
BaseConfig()
           
 
Method Summary
protected  Properties copyProperties()
          Return a copy of the properties held by this object.
 void freeze()
          Freeze the configuration of this action.
protected  Properties getProperties()
           Return the entire set of properties configured for this object.
 String getProperty(String key)
          Return the property-value for the specified key, if any; otherwise return null.
protected  void inheritProperties(BaseConfig baseConfig)
          Compare the properties of this config with that of the given and copy those that are not present.
protected  void setProperties(Properties properties)
          Set the entire set of properties configured for this object.
 void setProperty(String key, String value)
           Set an arbitary key/value pair which can be retrieved by this config class.
 void throwIfConfigured()
          Throw IllegalStateException if configuration is frozen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configured

protected boolean configured
Indicates if configuration of this component been completed. TODO change protected to private and use methods provided by extenders?

Constructor Detail

BaseConfig

public BaseConfig()
Method Detail

freeze

public void freeze()
Freeze the configuration of this action.


throwIfConfigured

public void throwIfConfigured()
Throw IllegalStateException if configuration is frozen.

Throws:
IllegalStateException - if configuration is frozen

setProperty

public void setProperty(String key,
                        String value)

Set an arbitary key/value pair which can be retrieved by this config class. This facility should eliminate many use cases for subclassing *Config classes by providing a mechanism to pass any amount of arbitrary configuration information into an config class.

This method must not be called after configuration is complete, or an IllegalStateException will be thrown.

Example

 <action path="/example" type="com.example.MyAction">
    <set-property key="foo" property="bar" />
 </action>
 

Parameters:
key - the key by which this value will be retrieved
value - the value to store with the supplied key
Throws:
IllegalStateException - if this module configuration has been frozen
Since:
Struts 1.3

getProperty

public String getProperty(String key)
Return the property-value for the specified key, if any; otherwise return null.

Parameters:
key - a key specified in the struts-config file
Returns:
the value stored with the supplied key
Since:
Struts 1.3

getProperties

protected Properties getProperties()

Return the entire set of properties configured for this object. At this time, this only needs to be exposed to support inheritance, so choosing a conservative access modifier ("protected").

Returns:
set of properties configured for this object

setProperties

protected void setProperties(Properties properties)
Set the entire set of properties configured for this object. At this time, this only needs to be exposed to support inheritance, so choosing a conservative access modifier ("protected").


inheritProperties

protected void inheritProperties(BaseConfig baseConfig)

Compare the properties of this config with that of the given and copy those that are not present. This method is used by subclasses that support configuration inheritance.

Parameters:
baseConfig - The config object to copy properties from.

copyProperties

protected Properties copyProperties()

Return a copy of the properties held by this object.



Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.