| java.lang.Object org.apache.struts2.config.MethodConfigurationProvider
MethodConfigurationProvider | public class MethodConfigurationProvider implements ConfigurationProvider(Code) | | MethodConfigurationProvider creates ActionConfigs for potential action
methods that lack a corresponding action mapping,
so that these methods can be invoked without extra or redundant configuration.
As a dynamic method, the behavior of this class could be represented as:
int bang = name.indexOf('!');
if (bang != -1) {
String method = name.substring(bang + 1);
mapping.setMethod(method);
name = name.substring(0, bang);
}
If the action URL is "foo!bar", the the "foo" action is invoked,
calling "bar" instead of "execute".
Instead of scanning each request at runtime, the provider creates action mappings
for each method that could be matched using a dynamic approach.
Advantages over a dynamic approach are that:
The "dynamic" methods are not a special case, but just another action mapping,
with all the features of a hardcoded mapping.
When needed, a manual action can be provided for a method and invoked with the same
syntax as an automatic action.
The ConfigBrowser can display all potential actions.
|
Field Summary | |
ObjectFactory | factory Stores ObjectFactory property. | boolean | reload Store needsReload property. |
Method Summary | |
protected boolean | addDynamicMethods(Map actions, String actionName, ActionConfig actionConfig) Scans class for potential Action mehods,
automatically generating and registering ActionConfigs as needed. | public void | destroy() | public void | init(Configuration configuration) | public void | loadPackages() | public boolean | needsReload() | public void | register(ContainerBuilder containerBuilder, LocatableProperties locatableProperties) | public void | setConfiguration(Configuration configuration) Updates configuration property. | public void | setObjectFactory(ObjectFactory factory) Updates ObjectFactory property. |
factory | ObjectFactory factory(Code) | | Stores ObjectFactory property.
|
reload | boolean reload(Code) | | Store needsReload property.
|
addDynamicMethods | protected boolean addDynamicMethods(Map actions, String actionName, ActionConfig actionConfig) throws ConfigurationException(Code) | | Scans class for potential Action mehods,
automatically generating and registering ActionConfigs as needed.
The system iterates over the set of namespaces and the set of actionNames
in a Configuration and retrieves each ActionConfig.
For each ActionConfig that invokes the default "execute" method,
the provider inspects the className class for other non-void,
no-argument methods that do not begin with "getX" or "isX".
For each qualifying method, the provider looks for another actionName in
the same namespace that equals action.name + "!" + method.name.
If that actionName is not found, System copies the ActionConfig,
changes the method property, and adds it to the package configuration
under the new actionName (action!method).
The system ignores ActionConfigs with a method property set so as to
avoid creating alias methods for alias methods.
The system ignores "getX" and "isX" methods since these would appear to be
JavaBeans property and would not be intended as action methods.
(The X represents any upper character or non-letter.)
Parameters: actions - All ActionConfigs in namespace Parameters: actionName - Name of ActionConfig to analyze Parameters: actionConfig - ActionConfig corresponding to actionName |
destroy | public void destroy()(Code) | | |
init | public void init(Configuration configuration) throws ConfigurationException(Code) | | |
loadPackages | public void loadPackages() throws ConfigurationException(Code) | | |
needsReload | public boolean needsReload()(Code) | | |
register | public void register(ContainerBuilder containerBuilder, LocatableProperties locatableProperties) throws ConfigurationException(Code) | | |
setConfiguration | public void setConfiguration(Configuration configuration)(Code) | | Updates configuration property.
Parameters: configuration - New configuration |
setObjectFactory | public void setObjectFactory(ObjectFactory factory)(Code) | | Updates ObjectFactory property.
Parameters: factory - |
|
|