org.apache.struts.config.impl
Class ModuleConfigImpl

java.lang.Object
  extended by org.apache.struts.config.BaseConfig
      extended by org.apache.struts.config.impl.ModuleConfigImpl
All Implemented Interfaces:
java.io.Serializable, ModuleConfig

public class ModuleConfigImpl
extends BaseConfig
implements java.io.Serializable, ModuleConfig

The collection of static configuration information that describes a Struts-based module. Multiple modules are identified by a prefix at the beginning of the context relative portion of the request URI. If no module prefix can be matched, the default configuration (with a prefix equal to a zero-length string) is selected, which is elegantly backwards compatible with the previous Struts behavior that only supported one module.

Since:
Struts 1.1
Version:
$Rev: 471754 $ $Date: 2005-12-31 03:57:16 -0500 (Sat, 31 Dec 2005) $
See Also:
Serialized Form

Field Summary
protected  java.util.HashMap actionConfigIds
          The set of action configuration for this module, if any, keyed by the actionId property.
protected  java.util.List actionConfigList
          The set of action configurations for this module, if any, listed in the order in which they are added.
protected  java.util.HashMap actionConfigs
          The set of action configurations for this module, if any, keyed by the path property.
protected  java.lang.String actionFormBeanClass
          The default class name to be used when creating action form bean instances.
protected  java.lang.String actionForwardClass
          The default class name to be used when creating action forward instances.
protected  java.lang.String actionMappingClass
          The default class name to be used when creating action mapping instances.
protected  ControllerConfig controllerConfig
          The controller configuration object for this module.
protected  java.util.HashMap exceptions
          The set of exception handling configurations for this module, if any, keyed by the type property.
protected  java.util.HashMap formBeans
          The set of form bean configurations for this module, if any, keyed by the name property.
protected  java.util.HashMap forwards
          The set of global forward configurations for this module, if any, keyed by the name property.
protected static org.apache.commons.logging.Log log
          Commons Logging instance.
protected  ActionConfigMatcher matcher
          Matches action config paths against compiled wildcard patterns
protected  java.util.HashMap messageResources
          The set of message resources configurations for this module, if any, keyed by the key property.
protected  java.util.ArrayList plugIns
          The set of configured plug-in Actions for this module, if any, in the order they were declared and configured.
protected  java.lang.String prefix
          The prefix of the context-relative portion of the request URI, used to select this configuration versus others supported by the controller servlet.
 
Fields inherited from class org.apache.struts.config.BaseConfig
configured
 
Constructor Summary
ModuleConfigImpl()
          Constructor for ModuleConfigImpl.
ModuleConfigImpl(java.lang.String prefix)
          Construct an ModuleConfigImpl object according to the specified parameter values.
 
Method Summary
 void addActionConfig(ActionConfig config)
           Ad d a new ActionConfig instance to the set associated with this module.
 void addExceptionConfig(ExceptionConfig config)
           Add a new ExceptionConfig instance to the set associated with this module.
 void addFormBeanConfig(FormBeanConfig config)
           Add a new FormBeanConfig instance to the set associated with this module.
 void addForwardConfig(ForwardConfig config)
           Add a new ForwardConfig instance to the set of global forwards associated with this module.
 void addMessageResourcesConfig(MessageResourcesConfig config)
           Add a new MessageResourcesConfig instance to the set associated with this module.
 void addPlugInConfig(PlugInConfig plugInConfig)
           Add a newly configured PlugInConfig instance to the set of plug-in Actions for this module.
 ActionConfig findActionConfig(java.lang.String path)
           Return the action configuration for the specified path, first looking a direct match, then if none found, a wildcard pattern match; otherwise return null.
 ActionConfig findActionConfigId(java.lang.String actionId)
          Returns the action configuration for the specifed action action identifier.
 ActionConfig[] findActionConfigs()
           Return the action configurations for this module.
 ExceptionConfig findException(java.lang.Class type)
          Find and return the ExceptionConfig instance defining how Exceptions of the specified type should be handled.
 ExceptionConfig findExceptionConfig(java.lang.String type)
           Return the exception configuration for the specified type, if any; otherwise return null.
 ExceptionConfig[] findExceptionConfigs()
           Return the exception configurations for this module.
 FormBeanConfig findFormBeanConfig(java.lang.String name)
           Return the form bean configuration for the specified key, if any; otherwise return null.
 FormBeanConfig[] findFormBeanConfigs()
           Return the form bean configurations for this module.
 ForwardConfig findForwardConfig(java.lang.String name)
           Return the forward configuration for the specified key, if any; otherwise return null.
 ForwardConfig[] findForwardConfigs()
           Return the form bean configurations for this module.
 MessageResourcesConfig findMessageResourcesConfig(java.lang.String key)
           Return the message resources configuration for the specified key, if any; otherwise return null.
 MessageResourcesConfig[] findMessageResourcesConfigs()
           Return the message resources configurations for this module.
 PlugInConfig[] findPlugInConfigs()
           Return the configured plug-in actions for this module.
 void freeze()
           Freeze the configuration of this module.
 java.lang.String getActionFormBeanClass()
          The default class name to be used when creating action form bean instances.
 java.lang.String getActionForwardClass()
           The default class name to be used when creating action forward instances.
 java.lang.String getActionMappingClass()
          The default class name to be used when creating action mapping instances.
 boolean getConfigured()
           Has this module been completely configured yet.
 ControllerConfig getControllerConfig()
          The controller configuration object for this module.
 java.lang.String getPrefix()
          The prefix of the context-relative portion of the request URI, used to select this configuration versus others supported by the controller servlet.
 void removeActionConfig(ActionConfig config)
           Remove the specified action configuration instance.
 void removeExceptionConfig(ExceptionConfig config)
           Remove the specified exception configuration instance.
 void removeFormBeanConfig(FormBeanConfig config)
           Remove the specified form bean configuration instance.
 void removeForwardConfig(ForwardConfig config)
           Remove the specified forward configuration instance.
 void removeMessageResourcesConfig(MessageResourcesConfig config)
           Remove the specified message resources configuration instance.
 void setActionFormBeanClass(java.lang.String actionFormBeanClass)
          The default class name to be used when creating action form bean instances.
 void setActionForwardClass(java.lang.String actionForwardClass)
           The default class name to be used when creating action forward instances.
 void setActionMappingClass(java.lang.String actionMappingClass)
           The default class name to be used when creating action mapping instances.
 void setControllerConfig(ControllerConfig cc)
          The controller configuration object for this module.
 void setPrefix(java.lang.String prefix)
          The prefix of the context-relative portion of the request URI, used to select this configuration versus others supported by the controller servlet.
 
Methods inherited from class org.apache.struts.config.BaseConfig
copyProperties, getProperties, getProperty, inheritProperties, setProperties, setProperty, throwIfConfigured
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

Commons Logging instance.


actionConfigs

protected java.util.HashMap actionConfigs

The set of action configurations for this module, if any, keyed by the path property.


actionConfigIds

protected java.util.HashMap actionConfigIds

The set of action configuration for this module, if any, keyed by the actionId property.


actionConfigList

protected java.util.List actionConfigList

The set of action configurations for this module, if any, listed in the order in which they are added.


exceptions

protected java.util.HashMap exceptions

The set of exception handling configurations for this module, if any, keyed by the type property.


formBeans

protected java.util.HashMap formBeans

The set of form bean configurations for this module, if any, keyed by the name property.


forwards

protected java.util.HashMap forwards

The set of global forward configurations for this module, if any, keyed by the name property.


messageResources

protected java.util.HashMap messageResources

The set of message resources configurations for this module, if any, keyed by the key property.


plugIns

protected java.util.ArrayList plugIns

The set of configured plug-in Actions for this module, if any, in the order they were declared and configured.


controllerConfig

protected ControllerConfig controllerConfig

The controller configuration object for this module.


prefix

protected java.lang.String prefix

The prefix of the context-relative portion of the request URI, used to select this configuration versus others supported by the controller servlet. A configuration with a prefix of a zero-length String is the default configuration for this web module.


actionFormBeanClass

protected java.lang.String actionFormBeanClass

The default class name to be used when creating action form bean instances.


actionMappingClass

protected java.lang.String actionMappingClass
The default class name to be used when creating action mapping instances.


actionForwardClass

protected java.lang.String actionForwardClass
The default class name to be used when creating action forward instances.


matcher

protected ActionConfigMatcher matcher

Matches action config paths against compiled wildcard patterns

Constructor Detail

ModuleConfigImpl

public ModuleConfigImpl()

Constructor for ModuleConfigImpl. Assumes default configuration.

Since:
Struts 1.2.8

ModuleConfigImpl

public ModuleConfigImpl(java.lang.String prefix)

Construct an ModuleConfigImpl object according to the specified parameter values.

Parameters:
prefix - Context-relative URI prefix for this module
Method Detail

getConfigured

public boolean getConfigured()

Has this module been completely configured yet. Once this flag has been set, any attempt to modify the configuration will return an IllegalStateException.

Specified by:
getConfigured in interface ModuleConfig

getControllerConfig

public ControllerConfig getControllerConfig()

The controller configuration object for this module.

Specified by:
getControllerConfig in interface ModuleConfig

setControllerConfig

public void setControllerConfig(ControllerConfig cc)

The controller configuration object for this module.

Specified by:
setControllerConfig in interface ModuleConfig
Parameters:
cc - The controller configuration object for this module.

getPrefix

public java.lang.String getPrefix()

The prefix of the context-relative portion of the request URI, used to select this configuration versus others supported by the controller servlet. A configuration with a prefix of a zero-length String is the default configuration for this web module.

Specified by:
getPrefix in interface ModuleConfig

setPrefix

public void setPrefix(java.lang.String prefix)

The prefix of the context-relative portion of the request URI, used to select this configuration versus others supported by the controller servlet. A configuration with a prefix of a zero-length String is the default configuration for this web module.

Specified by:
setPrefix in interface ModuleConfig
Parameters:
prefix - The prefix of the context-relative portion of the request URI.

getActionFormBeanClass

public java.lang.String getActionFormBeanClass()

The default class name to be used when creating action form bean instances.

Specified by:
getActionFormBeanClass in interface ModuleConfig

setActionFormBeanClass

public void setActionFormBeanClass(java.lang.String actionFormBeanClass)

The default class name to be used when creating action form bean instances.

Specified by:
setActionFormBeanClass in interface ModuleConfig
Parameters:
actionFormBeanClass - default class name to be used when creating action form bean instances.

getActionMappingClass

public java.lang.String getActionMappingClass()

The default class name to be used when creating action mapping instances.

Specified by:
getActionMappingClass in interface ModuleConfig

setActionMappingClass

public void setActionMappingClass(java.lang.String actionMappingClass)

The default class name to be used when creating action mapping instances.

Specified by:
setActionMappingClass in interface ModuleConfig
Parameters:
actionMappingClass - default class name to be used when creating action mapping instances.

addActionConfig

public void addActionConfig(ActionConfig config)

Ad d a new ActionConfig instance to the set associated with this module.

Specified by:
addActionConfig in interface ModuleConfig
Parameters:
config - The new configuration instance to be added
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

addExceptionConfig

public void addExceptionConfig(ExceptionConfig config)

Add a new ExceptionConfig instance to the set associated with this module.

Specified by:
addExceptionConfig in interface ModuleConfig
Parameters:
config - The new configuration instance to be added
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

addFormBeanConfig

public void addFormBeanConfig(FormBeanConfig config)

Add a new FormBeanConfig instance to the set associated with this module.

Specified by:
addFormBeanConfig in interface ModuleConfig
Parameters:
config - The new configuration instance to be added
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

getActionForwardClass

public java.lang.String getActionForwardClass()

The default class name to be used when creating action forward instances.

Specified by:
getActionForwardClass in interface ModuleConfig

setActionForwardClass

public void setActionForwardClass(java.lang.String actionForwardClass)

The default class name to be used when creating action forward instances.

Specified by:
setActionForwardClass in interface ModuleConfig
Parameters:
actionForwardClass - default class name to be used when creating action forward instances.

addForwardConfig

public void addForwardConfig(ForwardConfig config)

Add a new ForwardConfig instance to the set of global forwards associated with this module.

Specified by:
addForwardConfig in interface ModuleConfig
Parameters:
config - The new configuration instance to be added
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

addMessageResourcesConfig

public void addMessageResourcesConfig(MessageResourcesConfig config)

Add a new MessageResourcesConfig instance to the set associated with this module.

Specified by:
addMessageResourcesConfig in interface ModuleConfig
Parameters:
config - The new configuration instance to be added
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

addPlugInConfig

public void addPlugInConfig(PlugInConfig plugInConfig)

Add a newly configured PlugInConfig instance to the set of plug-in Actions for this module.

Specified by:
addPlugInConfig in interface ModuleConfig
Parameters:
plugInConfig - The new configuration instance to be added

findActionConfig

public ActionConfig findActionConfig(java.lang.String path)

Return the action configuration for the specified path, first looking a direct match, then if none found, a wildcard pattern match; otherwise return null.

Specified by:
findActionConfig in interface ModuleConfig
Parameters:
path - Path of the action configuration to return

findActionConfigId

public ActionConfig findActionConfigId(java.lang.String actionId)

Returns the action configuration for the specifed action action identifier.

Specified by:
findActionConfigId in interface ModuleConfig
Parameters:
actionId - the action identifier
Returns:
the action config if found; otherwise null
Since:
Struts 1.3.6
See Also:
ActionConfig.getActionId()

findActionConfigs

public ActionConfig[] findActionConfigs()

Return the action configurations for this module. If there are none, a zero-length array is returned.

Specified by:
findActionConfigs in interface ModuleConfig

findExceptionConfig

public ExceptionConfig findExceptionConfig(java.lang.String type)

Return the exception configuration for the specified type, if any; otherwise return null.

Specified by:
findExceptionConfig in interface ModuleConfig
Parameters:
type - Exception class name to find a configuration for

findException

public ExceptionConfig findException(java.lang.Class type)

Find and return the ExceptionConfig instance defining how Exceptions of the specified type should be handled.

In original Struts usage, this was only available in ActionConfig, but there are cases when an exception could be thrown before an ActionConfig has been identified, where global exception handlers may still be pertinent.

TODO: Look for a way to share this logic with ActionConfig, although there are subtle differences, and it certainly doesn't seem like it should be done with inheritance.

Specified by:
findException in interface ModuleConfig
Parameters:
type - Exception class for which to find a handler
Since:
Struts 1.3.0
See Also:
findException(Class)

findExceptionConfigs

public ExceptionConfig[] findExceptionConfigs()

Return the exception configurations for this module. If there are none, a zero-length array is returned.

Specified by:
findExceptionConfigs in interface ModuleConfig

findFormBeanConfig

public FormBeanConfig findFormBeanConfig(java.lang.String name)

Return the form bean configuration for the specified key, if any; otherwise return null.

Specified by:
findFormBeanConfig in interface ModuleConfig
Parameters:
name - Name of the form bean configuration to return

findFormBeanConfigs

public FormBeanConfig[] findFormBeanConfigs()

Return the form bean configurations for this module. If there are none, a zero-length array is returned.

Specified by:
findFormBeanConfigs in interface ModuleConfig

findForwardConfig

public ForwardConfig findForwardConfig(java.lang.String name)

Return the forward configuration for the specified key, if any; otherwise return null.

Specified by:
findForwardConfig in interface ModuleConfig
Parameters:
name - Name of the forward configuration to return

findForwardConfigs

public ForwardConfig[] findForwardConfigs()

Return the form bean configurations for this module. If there are none, a zero-length array is returned.

Specified by:
findForwardConfigs in interface ModuleConfig

findMessageResourcesConfig

public MessageResourcesConfig findMessageResourcesConfig(java.lang.String key)

Return the message resources configuration for the specified key, if any; otherwise return null.

Specified by:
findMessageResourcesConfig in interface ModuleConfig
Parameters:
key - Key of the data source configuration to return

findMessageResourcesConfigs

public MessageResourcesConfig[] findMessageResourcesConfigs()

Return the message resources configurations for this module. If there are none, a zero-length array is returned.

Specified by:
findMessageResourcesConfigs in interface ModuleConfig

findPlugInConfigs

public PlugInConfig[] findPlugInConfigs()

Return the configured plug-in actions for this module. If there are none, a zero-length array is returned.

Specified by:
findPlugInConfigs in interface ModuleConfig

freeze

public void freeze()

Freeze the configuration of this module. After this method returns, any attempt to modify the configuration will return an IllegalStateException.

Specified by:
freeze in interface ModuleConfig
Overrides:
freeze in class BaseConfig

removeActionConfig

public void removeActionConfig(ActionConfig config)

Remove the specified action configuration instance.

Specified by:
removeActionConfig in interface ModuleConfig
Parameters:
config - ActionConfig instance to be removed
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

removeExceptionConfig

public void removeExceptionConfig(ExceptionConfig config)

Remove the specified exception configuration instance.

Specified by:
removeExceptionConfig in interface ModuleConfig
Parameters:
config - ActionConfig instance to be removed
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

removeFormBeanConfig

public void removeFormBeanConfig(FormBeanConfig config)

Remove the specified form bean configuration instance.

Specified by:
removeFormBeanConfig in interface ModuleConfig
Parameters:
config - FormBeanConfig instance to be removed
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

removeForwardConfig

public void removeForwardConfig(ForwardConfig config)

Remove the specified forward configuration instance.

Specified by:
removeForwardConfig in interface ModuleConfig
Parameters:
config - ForwardConfig instance to be removed
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen

removeMessageResourcesConfig

public void removeMessageResourcesConfig(MessageResourcesConfig config)

Remove the specified message resources configuration instance.

Specified by:
removeMessageResourcesConfig in interface ModuleConfig
Parameters:
config - MessageResourcesConfig instance to be removed
Throws:
java.lang.IllegalStateException - if this module configuration has been frozen


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