Version 4.10.0

Class RequestParserImpl

  extended by hirondelle.web4j.request.RequestParser
      extended by hirondelle.web4j.request.RequestParserImpl

public class RequestParserImpl
extends RequestParser

Maps each HTTP request to a concrete Action.

Default implementation of RequestParser.

This implementation extracts the URI Mapping String from the underlying request, and maps it to a specific Action class, and calls its constructor by passing a RequestParser. (Here, each Action must have a public constructor which takes a RequestParser as its single parameter.)

There are two kinds of mapping available :

URI Mapping String

The 'URI Mapping String' is extracted from the underlying request. It is simply the concatention of HttpServletRequest.getServletPath() and HttpServletRequest.getPathInfo() (minus the extension - .do, for example).

(The servlet path is the part of the URI which has been mapped to a servlet by the servlet-mapping entries in the web.xml.)

Implicit Mapping

If no explicit mapping exists in an Action, then it will implicitly map to the URI Mapping String that corresponds to a modified version of its package-qualified name :

Example of an implicit mapping :

ImplicitMappingRemoveBasePackage (web.xml)
Implicit Mapping calculated as:/main/member/MemberEdit

Which maps to the following requests:

Request 1:
Request 2:
URI Mapping String calculated as:/main/member/MemberEdit

Explicit Mapping

An Action may declare an explicit mapping to a URI Mapping String simply by declaring a field of the form (for example) :
  public static final String EXPLICIT_URI_MAPPING = "/translate/basetext/BaseTextEdit";
Explicit mappings override implicit mappings.

Fine-Grained Security

Fine-grained security allows <security-constraint> items to be specifed for various extensions, where the extensions represent various action verbs, such as .list, .change, and so on. In that case, the conventional .do is replaced with several different extensions. See the User Guide for more information on fine-grained security.

Looking Up Action, Given URI

It's a common requirement to look up an action class, given a URI. Various sources can be used to perform that task:

Constructor Summary
RequestParserImpl(HttpServletRequest aRequest, HttpServletResponse aResponse)
Method Summary
static String getImplicitMappingRemoveBasePackage()
          Return the String configured in web.xml as being the base or root package that is to be ignored by the default Action mapping mechanism.
 Action getWebAction()
          Map an HTTP request to a concrete implementation of Action.
static void initWebActionMappings()
          Scan for Action mappings.
Methods inherited from class hirondelle.web4j.request.RequestParser
getInstance, getRawParamValue, getRawParamValues, getRequest, getResponse, isFileUploadRequest, toId, toIds, toSafeText, toSafeTexts, toSupportedObject, toSupportedObjects
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public RequestParserImpl(HttpServletRequest aRequest,
                         HttpServletResponse aResponse)

aRequest - passed to the super class.
aResponse - passed to the super class.
Method Detail


public static void initWebActionMappings()
Scan for Action mappings. Called by the framework upon startup. Scans for all classes that implement Action. Stores either an implicit or an explicit mapping. Implicit mappings are the recommended style.

If a problem with mapping is detected, then a RuntimeException is thrown, and the application will not load. This protects the application, by forcing some important errors to occur during startup, instead of during normal operation. Possible errors include :


public final Action getWebAction()
Map an HTTP request to a concrete implementation of Action.

Extract the URI Mapping String from the underlying request, and map it to an Action.

Specified by:
getWebAction in class RequestParser


public static final String getImplicitMappingRemoveBasePackage()
Return the String configured in web.xml as being the base or root package that is to be ignored by the default Action mapping mechanism. See web.xml for more information.

Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.