Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.dispatcher.mapper
Class CompositeActionMapper

    java.lang.Object
      org.apache.struts2.dispatcher.mapper.CompositeActionMapper

All Implemented Interfaces:
  ActionMapper

    public class CompositeActionMapper

extends java.lang.Object
implements 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.RestfulActionMapper,org.apache.struts2.dispatcher.mapper.Restful2ActionMapper" />

When `getMapping(HttpServletRequest, ConfigurationManager)` or `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 `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.

Version:
  $Date: 2009-07-07 19:47:34 +0200 (Tue, 07 Jul 2009) $ $Id: CompositeActionMapper.java 791919 2009-07-07 17:47:34Z musachy $
See Also:
  `ActionMapper`, `ActionMapping`

Field Summary
`protected java.util.List<ActionMapper>` | `actionMappers`
`protected Container` | `container`

Constructor Summary
`CompositeActionMapper()`

Method Summary
`ActionMapping` | `getMapping(javax.servlet.http.HttpServletRequest request, ConfigurationManager configManager)` Expose the ActionMapping for the current request
`ActionMapping` | `getMappingFromActionName(java.lang.String actionName)` Expose the ActionMapping for the specified action name
`java.lang.String` | `getUriFromActionMapping(ActionMapping mapping)` Convert an ActionMapping into a URI string
`void` | `setActionMappers(java.lang.String list)`
`void` | `setContainer(Container container)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### container

    protected Container container

### actionMappers

    protected java.util.List<ActionMapper> actionMappers

Constructor Detail

### CompositeActionMapper

    public CompositeActionMapper()

Method Detail

### setContainer

    public void setContainer(Container container)

### setActionMappers

    public void setActionMappers(java.lang.String list)

### getMapping

    public ActionMapping getMapping(javax.servlet.http.HttpServletRequest request,
                                    ConfigurationManager configManager)

  Description copied from interface: `ActionMapper`
  Expose the ActionMapping for the current request

  Specified by:
    `getMapping` in interface `ActionMapper`
  Parameters:
    `request` - The servlet request
    `configManager` - The current configuration manager
  Returns:
    The appropriate action mapping

### getMappingFromActionName

    public ActionMapping getMappingFromActionName(java.lang.String actionName)

  Description copied from interface: `ActionMapper`
  Expose the ActionMapping for the specified action name

  Specified by:
    `getMappingFromActionName` in interface `ActionMapper`
  Parameters:
    `actionName` - The name of the action that may have other information embedded in it
  Returns:
    The appropriate action mapping

### getUriFromActionMapping

    public java.lang.String getUriFromActionMapping(ActionMapping mapping)

  Description copied from interface: `ActionMapper`
  Convert an ActionMapping into a URI string

  Specified by:
    `getUriFromActionMapping` in interface `ActionMapper`
  Parameters:
    `mapping` - The action mapping
  Returns:
    The URI string that represents this mapping

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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