public abstract class BaseConfig extends Object implements Serializable
A abstract base class for all config classes. Provide basic support for arbitrary properties
Modifier and Type | Field and Description |
---|---|
protected boolean |
configured
Indicates if configuration of this component been completed.
|
Constructor and Description |
---|
BaseConfig() |
Modifier and Type | Method and Description |
---|---|
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. |
protected boolean configured
public void freeze()
public void throwIfConfigured()
IllegalStateException
if configuration is frozen.IllegalStateException
- if configuration is frozenpublic 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.
IllegalStateException
will be thrown.
Example
<action path="/example" type="com.example.MyAction">
<set-property key="foo" property="bar" />
</action>
key
- the key by which this value will be retrievedvalue
- the value to store with the supplied keyIllegalStateException
- if this module configuration has been
frozenpublic String getProperty(String key)
null
.key
- a key specified in the struts-config
fileprotected 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").
protected void setProperties(Properties properties)
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.
baseConfig
- The config object to copy properties from.protected Properties copyProperties()
Return a copy of the properties held by this object.
Copyright © 2000–2017 Apache Software Foundation. All rights reserved.