Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » dispatcher » mapper » [javadoc | source]
org.apache.struts2.dispatcher.mapper
public class: CompositeActionMapper [javadoc | source]
java.lang.Object
   org.apache.struts2.dispatcher.mapper.CompositeActionMapper

All Implemented Interfaces:
    ActionMapper

A composite action mapper that is capable of delegating to a series of 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.RestfulActionMapperorg.apache.struts2.dispatcher.mapper.Restful2ActionMapper" />

When CompositeActionMapper#getMapping(HttpServletRequest, ConfigurationManager) or CompositeActionMapper#getUriFromActionMapping(ActionMapping) is invoked, CompositeActionMapper would go through these ActionMapper s 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 CompositeActionMapper#getMapping(HttpServletRequest, ConfigurationManager) and CompositeActionMapper#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.

Field Summary
protected  Container container     
protected  List actionMappers     
Method from org.apache.struts2.dispatcher.mapper.CompositeActionMapper Summary:
getMapping,   getUriFromActionMapping,   setActionMappers,   setContainer
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.dispatcher.mapper.CompositeActionMapper Detail:
 public ActionMapping getMapping(HttpServletRequest request,
    ConfigurationManager configManager) 
 public String getUriFromActionMapping(ActionMapping mapping) 
 public  void setActionMappers(String list) 
 public  void setContainer(Container container)