org.apache.struts2.rest
Class RestActionMapper

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

public class RestActionMapper
extends DefaultActionMapper

This Restful action mapper enforces Ruby-On-Rails Rest-style mappings. If the method is not specified (via '!' or 'method:' prefix), the method is "guessed" at using ReST-style conventions that examine the URL and the HTTP method. Special care has been given to ensure this mapper works correctly with the codebehind plugin so that XML configuration is unnecessary.

This mapper supports the following parameters:

The following URL's will invoke its methods:

To simulate the HTTP methods PUT and DELETE, since they aren't supported by HTML, the HTTP parameter "_method" will be used.


Field Summary
static java.lang.String HTTP_METHOD_PARAM
           
protected static Logger LOG
           
 
Fields inherited from class org.apache.struts2.dispatcher.mapper.DefaultActionMapper
ACTION_PREFIX, allowSlashesInActionNames, alwaysSelectFullNamespace, container, extensions, METHOD_PREFIX, prefixTrie, REDIRECT_ACTION_PREFIX, REDIRECT_PREFIX
 
Constructor Summary
RestActionMapper()
           
 
Method Summary
 java.lang.String getIdParameterName()
           
 ActionMapping getMapping(javax.servlet.http.HttpServletRequest request, ConfigurationManager configManager)
           
protected  boolean isDelete(javax.servlet.http.HttpServletRequest request)
           
protected  boolean isExpectContinue(javax.servlet.http.HttpServletRequest request)
           
protected  boolean isGet(javax.servlet.http.HttpServletRequest request)
           
protected  boolean isOptions(javax.servlet.http.HttpServletRequest request)
           
protected  boolean isPost(javax.servlet.http.HttpServletRequest request)
           
protected  boolean isPut(javax.servlet.http.HttpServletRequest request)
           
protected  void parseNameAndNamespace(java.lang.String uri, ActionMapping mapping, ConfigurationManager configManager)
          Parses the name and namespace from the uri.
 void setAllowDynamicMethodCalls(java.lang.String allowDynamicMethodCalls)
           
 void setDeleteMethodName(java.lang.String deleteMethodName)
           
 void setEditMethodName(java.lang.String editMethodName)
           
 void setGetMethodName(java.lang.String getMethodName)
           
 void setIdParameterName(java.lang.String idParameterName)
           
 void setIndexMethodName(java.lang.String indexMethodName)
           
 void setNewMethodName(java.lang.String newMethodName)
           
 void setOptionsMethodName(java.lang.String optionsMethodName)
           
 void setPostContinueMethodName(java.lang.String postContinueMethodName)
           
 void setPostMethodName(java.lang.String postMethodName)
           
 void setPutContinueMethodName(java.lang.String putContinueMethodName)
           
 void setPutMethodName(java.lang.String putMethodName)
           
 
Methods inherited from class org.apache.struts2.dispatcher.mapper.DefaultActionMapper
addParameterAction, dropExtension, dropExtension, getDefaultExtension, getMappingFromActionName, getUri, getUriFromActionMapping, handleSpecialParameters, isSlashesInActionNames, parseActionName, setAlwaysSelectFullNamespace, setContainer, setExtensions, setSlashesInActionNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final Logger LOG

HTTP_METHOD_PARAM

public static final java.lang.String HTTP_METHOD_PARAM
See Also:
Constant Field Values
Constructor Detail

RestActionMapper

public RestActionMapper()
Method Detail

getIdParameterName

public java.lang.String getIdParameterName()

setIdParameterName

public void setIdParameterName(java.lang.String idParameterName)

setIndexMethodName

public void setIndexMethodName(java.lang.String indexMethodName)

setGetMethodName

public void setGetMethodName(java.lang.String getMethodName)

setPostMethodName

public void setPostMethodName(java.lang.String postMethodName)

setEditMethodName

public void setEditMethodName(java.lang.String editMethodName)

setNewMethodName

public void setNewMethodName(java.lang.String newMethodName)

setDeleteMethodName

public void setDeleteMethodName(java.lang.String deleteMethodName)

setPutMethodName

public void setPutMethodName(java.lang.String putMethodName)

setOptionsMethodName

public void setOptionsMethodName(java.lang.String optionsMethodName)

setPostContinueMethodName

public void setPostContinueMethodName(java.lang.String postContinueMethodName)

setPutContinueMethodName

public void setPutContinueMethodName(java.lang.String putContinueMethodName)

setAllowDynamicMethodCalls

public void setAllowDynamicMethodCalls(java.lang.String allowDynamicMethodCalls)
Overrides:
setAllowDynamicMethodCalls in class DefaultActionMapper

getMapping

public ActionMapping getMapping(javax.servlet.http.HttpServletRequest request,
                                ConfigurationManager configManager)
Specified by:
getMapping in interface ActionMapper
Overrides:
getMapping in class DefaultActionMapper

parseNameAndNamespace

protected void parseNameAndNamespace(java.lang.String uri,
                                     ActionMapping mapping,
                                     ConfigurationManager configManager)
Parses the name and namespace from the uri. Uses the configured package namespaces to determine the name and id parameter, to be parsed later.

Overrides:
parseNameAndNamespace in class DefaultActionMapper
Parameters:
uri - The uri
mapping - The action mapping to populate

isGet

protected boolean isGet(javax.servlet.http.HttpServletRequest request)

isPost

protected boolean isPost(javax.servlet.http.HttpServletRequest request)

isPut

protected boolean isPut(javax.servlet.http.HttpServletRequest request)

isDelete

protected boolean isDelete(javax.servlet.http.HttpServletRequest request)

isOptions

protected boolean isOptions(javax.servlet.http.HttpServletRequest request)

isExpectContinue

protected boolean isExpectContinue(javax.servlet.http.HttpServletRequest request)


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