|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.config.MethodConfigurationProvider
public class MethodConfigurationProvider
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:
Field Summary | |
---|---|
private Configuration |
configuration
Stores configuration property. |
(package private) ObjectFactory |
factory
Stores ObjectFactory property. |
(package private) boolean |
reload
Store needsReload property. |
Constructor Summary | |
---|---|
MethodConfigurationProvider()
|
Method Summary | |
---|---|
protected boolean |
addDynamicMethods(Map actions,
String actionName,
ActionConfig actionConfig)
Scans class for potential Action mehods, automatically generating and registering ActionConfigs as needed. |
void |
destroy()
|
private ObjectFactory |
getObjectFactory()
Provides ObjectFactory property. |
void |
init(Configuration configuration)
|
void |
loadPackages()
|
boolean |
needsReload()
Tells whether the ConfigurationProvider should reload its configuration |
void |
register(ContainerBuilder containerBuilder,
LocatableProperties locatableProperties)
|
void |
setConfiguration(Configuration configuration)
Updates configuration property. |
void |
setObjectFactory(ObjectFactory factory)
Updates ObjectFactory property. |
private boolean |
upperAt(int pos,
String string)
Verifies that character at a String position is upper case. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Configuration configuration
boolean reload
ObjectFactory factory
Constructor Detail |
---|
public MethodConfigurationProvider()
Method Detail |
---|
public void setConfiguration(Configuration configuration)
configuration
- New configurationpublic void destroy()
destroy
in interface ConfigurationProvider
public void init(Configuration configuration) throws ConfigurationException
init
in interface ConfigurationProvider
ConfigurationException
public void register(ContainerBuilder containerBuilder, LocatableProperties locatableProperties) throws ConfigurationException
register
in interface ConfigurationProvider
ConfigurationException
public void loadPackages() throws ConfigurationException
loadPackages
in interface ConfigurationProvider
ConfigurationException
public boolean needsReload()
ConfigurationProvider
needsReload
in interface ConfigurationProvider
public void setObjectFactory(ObjectFactory factory)
factory
- private ObjectFactory getObjectFactory() throws ConfigurationException
ConfigurationException
- if ObjectFactory has not been set.private boolean upperAt(int pos, String string)
pos
- Position to teststring
- Text containing position
protected boolean addDynamicMethods(Map actions, String actionName, ActionConfig actionConfig) throws ConfigurationException
actions
- All ActionConfigs in namespaceactionName
- Name of ActionConfig to analyzeactionConfig
- ActionConfig corresponding to actionName
ConfigurationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |