com.arsdigita.acs
Class RequestProcessor

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.arsdigita.acs.RequestProcessor
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class RequestProcessor
extends javax.servlet.http.HttpServlet

Request procesor servlet for ACS -- handles abstract URLs and sets up request/session/package objects.

When this servlet is mapped to "/" in the acs-java context, it will handle all requests in the context that do not have a specific servlet associated with them. This is necessary for dynamically mapping and re-mapping virtual paths to packages at the application layer, so that a package (e.g., packages/bboard) can be mounted on multiple URLs (/service/discussion, /service/forum, etc.)

When a request comes in:

  1. We build an ACSSession object for the session, which reads the cookies from the request; this object's methods are used to find out who's logged in and authenticate the user.
  2. We try to resolve the request for a URL to a package instance by building ACSRequest and ACSPackage objects.
  3. If we don't resolve the request to a package, we assume it's in the global pageroot (/www). Otherwise we resolve the requested page to /packages/PACKAGE-KEY/path/file.
  4. Check to make sure that the user is authorized to access the particular object id/site node.
  5. If the requested file is an "abstract" pathname (without extension), we resolve the URL to a file by trying different extensions
  6. Once we have the exact URL of the file to be served, we grab the proper handling servlet for the file by URL and forward the request.
  7. When there is no servlet explicitly mapped to handle a particular file (e.g., static HTML, graphics, etc.), the servlet engine will forward the request for /path/page.{gif,jpeg,html,etc.} to the RequestProcessor servlet a second time, because it is mounted on "/". The RequestProcessor detects re-entrant calls and then forwards to the named "default" servlet to serve the page. (NB: the "default" servlet must be registered/published in web.xml)

See Also:
Serialized Form

Field Summary
static java.lang.String cvsId
           
 
Constructor Summary
RequestProcessor()
           
 
Method Summary
static RequestProcessor getInstance()
          Returns the currently-loaded instance of the request processor servlet.
static java.util.ArrayList getSupportedExtensions()
           
 void init()
          Called when servlet is loaded, and sets static instance.
static void registerExtensionHandler(java.lang.String ext, ExtensionHandler h)
           
static void registerTranslatorHandler(java.lang.String ext, TranslatorHandler h)
           
static java.lang.String runTranslations(java.lang.String originalUrl, java.io.File fileToTranslate)
           
 void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Handles an abstract URL in the request req, and sets up objects for the session, request, and package.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvsId

public static final java.lang.String cvsId
Constructor Detail

RequestProcessor

public RequestProcessor()
Method Detail

getInstance

public static RequestProcessor getInstance()
Returns the currently-loaded instance of the request processor servlet.
Returns:
The current JVM's RequestProcessor instance.

init

public void init()
          throws javax.servlet.ServletException
Called when servlet is loaded, and sets static instance. Also initializes an instance of the AJP compiler.
Overrides:
init in class javax.servlet.GenericServlet

service

public void service(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse resp)
             throws javax.servlet.ServletException,
                    java.io.IOException
Handles an abstract URL in the request req, and sets up objects for the session, request, and package. Forwards the request as appropriate.
Overrides:
service in class javax.servlet.http.HttpServlet
Parameters:
req - The servlet request.
resp - The servlet response.

runTranslations

public static java.lang.String runTranslations(java.lang.String originalUrl,
                                               java.io.File fileToTranslate)
                                        throws javax.servlet.ServletException

getSupportedExtensions

public static java.util.ArrayList getSupportedExtensions()

registerTranslatorHandler

public static void registerTranslatorHandler(java.lang.String ext,
                                             TranslatorHandler h)

registerExtensionHandler

public static void registerExtensionHandler(java.lang.String ext,
                                            ExtensionHandler h)