public class CompositeActionMapper extends Object implements ActionMapper
ActionMapper if the former
failed to obtained a valid ActionMapping or uri.
It is configured through struts.properties.
For example, with the following entries in struts.properties
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="struts"
class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />
<constant name="struts.mapper.composite"
value="org.apache.struts2.dispatcher.mapper.DefaultActionMapper,org.apache.struts2.dispatcher.mapper.RestfulActionMapper,org.apache.struts2.dispatcher.mapper.Restful2ActionMapper" />
When getMapping(HttpServletRequest, ConfigurationManager) or
getUriFromActionMapping(ActionMapping) is invoked,
CompositeActionMapper would go through these ActionMappers in sequence
starting from ActionMapper identified by 'struts.mapper.composite.1', followed by
'struts.mapper.composite.2' and finally 'struts.mapper.composite.3' (in this case) until either
one of the ActionMapper return a valid result (not null) or it runs out of ActionMapper
in which case it will just return null for both
getMapping(HttpServletRequest, ConfigurationManager) and
getUriFromActionMapping(ActionMapping) methods.
For example with the following in struts-*.xml :-
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="struts"
class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />
<constant name="struts.mapper.composite"
value="org.apache.struts2.dispatcher.mapper.DefaultActionMapper,foo.bar.MyActionMapper,foo.bar.MyAnotherActionMapper" />
CompositeActionMapper will be configured with 3 ActionMapper, namely
"DefaultActionMapper", "MyActionMapper" and "MyAnotherActionMapper".
CompositeActionMapper would consult each of them in order described above.
ActionMapper,
ActionMapping| Modifier and Type | Field and Description |
|---|---|
protected List<ActionMapper> |
actionMappers |
protected Container |
container |
| Constructor and Description |
|---|
CompositeActionMapper(Container container) |
| Modifier and Type | Method and Description |
|---|---|
ActionMapping |
getMapping(javax.servlet.http.HttpServletRequest request,
ConfigurationManager configManager)
Expose the ActionMapping for the current request
|
ActionMapping |
getMappingFromActionName(String actionName)
Expose the ActionMapping for the specified action name
|
String |
getUriFromActionMapping(ActionMapping mapping)
Convert an ActionMapping into a URI string
|
void |
setActionMappers(String list) |
protected Container container
protected List<ActionMapper> actionMappers
public CompositeActionMapper(Container container)
public void setActionMappers(String list)
public ActionMapping getMapping(javax.servlet.http.HttpServletRequest request, ConfigurationManager configManager)
ActionMappergetMapping in interface ActionMapperrequest - The servlet requestconfigManager - The current configuration managerpublic ActionMapping getMappingFromActionName(String actionName)
ActionMappergetMappingFromActionName in interface ActionMapperactionName - The name of the action that may have other information embedded in itpublic String getUriFromActionMapping(ActionMapping mapping)
ActionMappergetUriFromActionMapping in interface ActionMappermapping - The action mappingCopyright © 2000-2013 Apache Software Foundation. All Rights Reserved.