org.apache.struts2.dispatcher.mapper
Class PrefixBasedActionMapper

java.lang.Object
  extended by org.apache.struts2.dispatcher.mapper.DefaultActionMapper
      extended by org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper
All Implemented Interfaces:
ActionMapper

public class PrefixBasedActionMapper
extends DefaultActionMapper
implements ActionMapper

A prefix based action mapper that is capable of delegating to other ActionMappers based on the request's prefix It is configured through struts.xml For example, with the following entries in struts.properties

 <constant name="struts.mapper.class" value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper"/>
 <constant name="struts.mapper.prefixMapping" value="/communities:pseudoRestful,/communityTags:pseudoRestful,/events:pseudoRestful,/mediaList:pseudoRestful,/users:pseudoRestful,/community:struts,/communityTag:struts,/event:struts,/media:struts,/user:struts,:struts"/>
 

When getMapping(HttpServletRequest, ConfigurationManager) or getUriFromActionMapping(ActionMapping) is invoked, PrefixBasedActionMapper will check each possible prefix (url prefix terminating just before a /) to find the most specific ActionMapper that returns a mapping when asked to map the request. If none are found, null is returned for both getMapping(HttpServletRequest, ConfigurationManager) and getUriFromActionMapping(ActionMapping) methods.

See Also:
ActionMapper, ActionMapping

Field Summary
protected  Map<String,ActionMapper> actionMappers
           
protected  Container container
           
protected  org.apache.commons.logging.Log log
           
 
Fields inherited from class org.apache.struts2.dispatcher.mapper.DefaultActionMapper
ACTION_PREFIX, allowDynamicMethodCalls, allowSlashesInActionNames, alwaysSelectFullNamespace, extensions, METHOD_PREFIX, prefixTrie, REDIRECT_ACTION_PREFIX, REDIRECT_PREFIX
 
Constructor Summary
PrefixBasedActionMapper()
           
 
Method Summary
 ActionMapping getMapping(javax.servlet.http.HttpServletRequest request, ConfigurationManager configManager)
          Expose the ActionMapping for the current request
 String getUriFromActionMapping(ActionMapping mapping)
          Convert an ActionMapping into a URI string
 void setContainer(Container container)
           
 void setPrefixBasedActionMappers(String list)
           
 
Methods inherited from class org.apache.struts2.dispatcher.mapper.DefaultActionMapper
addParameterAction, dropExtension, dropExtension, getDefaultExtension, getMappingFromActionName, getUri, handleSpecialParameters, isSlashesInActionNames, parseActionName, parseNameAndNamespace, setAllowDynamicMethodCalls, setAlwaysSelectFullNamespace, setExtensions, setSlashesInActionNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.struts2.dispatcher.mapper.ActionMapper
getMappingFromActionName
 

Field Detail

log

protected final transient org.apache.commons.logging.Log log

container

protected Container container

actionMappers

protected Map<String,ActionMapper> actionMappers
Constructor Detail

PrefixBasedActionMapper

public PrefixBasedActionMapper()
Method Detail

setContainer

public void setContainer(Container container)
Overrides:
setContainer in class DefaultActionMapper

setPrefixBasedActionMappers

public void setPrefixBasedActionMappers(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
Overrides:
getMapping in class DefaultActionMapper
Parameters:
request - The servlet request
configManager - The current configuration manager
Returns:
The appropriate action mapping

getUriFromActionMapping

public String getUriFromActionMapping(ActionMapping mapping)
Description copied from interface: ActionMapper
Convert an ActionMapping into a URI string

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


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