com.arsdigita.cms.dispatcher
Class ServiceDispatcher

java.lang.Object
  extended bycom.arsdigita.util.LockableImpl
      extended bycom.arsdigita.cms.dispatcher.ServiceDispatcher
All Implemented Interfaces:
com.arsdigita.dispatcher.Dispatcher, com.arsdigita.util.Lockable

public class ServiceDispatcher
extends com.arsdigita.util.LockableImpl
implements com.arsdigita.dispatcher.Dispatcher

The Service Dispatcher handles common services shared across all CMS instances. This dispatcher is called by the Subsite dispatcher.

Here are the steps for a request to http://yourserver/cms-service/cheese:

  1. A client sends a request to the web server, which passes it on to the global ACS dispatcher.

  2. The global ACS dispatcher examines the first part of the URL, notices that the Content Center application is mounted at /cms-service and hands the request to the CMS Service dispatcher.

  3. The CMS Service dispatcher determines whether a Page has been registered to the URL /cheese.

  4. If no Page is registered to the URL /cheese, then the CMS Service dispatcher hands the request to the JSPApplicationDispatcher, which serves JSPs and static content from the /packages/cms/www.

Version:
$Revision: #12 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Michael Pih (pihman@arsdigita.com)

Nested Class Summary
protected static class ServiceDispatcher.PageClassConfigHandler
          SAX event handler class for parsing configuration file.
 
Field Summary
static String versionId
           
 
Constructor Summary
ServiceDispatcher()
           
 
Method Summary
protected  void addResource(String url, String className)
          Map a page to a URL.
protected  void checkUserAccess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.arsdigita.dispatcher.RequestContext actx)
          Deprecated. subclasses of ResourceHandler should check the permissions directly on the ContentItem being served. This method currently acts as a no-op
 void dispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.arsdigita.dispatcher.RequestContext actx)
          Handles requests made to the Content Center package.
protected  ResourceHandler getResource(String url)
          Fetch a page based on the URL stub.
protected  org.xml.sax.helpers.DefaultHandler newParseConfigHandler(Map map)
          Expirimental Returns a SAX event handler object for setting up a MapDispatcher using an XML config file.
protected  void redirectToLoginPage(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Redirects the client to the login page, setting the return url to the current request URI.
static void releaseResource(String url)
          Release the page at the specified URL.
 void requireTrailingSlash(String url)
          Adds a URL to the list of URLs that are required to have trailing slashes.
 void setNotFoundDispatcher(com.arsdigita.dispatcher.Dispatcher d)
          sets the default page to display if no page can be found for the URL in the page map on dispatch.
 
Methods inherited from class com.arsdigita.util.LockableImpl
isLocked, lock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

ServiceDispatcher

public ServiceDispatcher()
Method Detail

dispatch

public void dispatch(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     com.arsdigita.dispatcher.RequestContext actx)
              throws IOException,
                     javax.servlet.ServletException
Handles requests made to the Content Center package.

Specified by:
dispatch in interface com.arsdigita.dispatcher.Dispatcher
Parameters:
request - The HTTP request
response - The HTTP response
actx - The request context
Throws:
IOException
javax.servlet.ServletException

setNotFoundDispatcher

public final void setNotFoundDispatcher(com.arsdigita.dispatcher.Dispatcher d)
sets the default page to display if no page can be found for the URL in the page map on dispatch.


requireTrailingSlash

public void requireTrailingSlash(String url)
Adds a URL to the list of URLs that are required to have trailing slashes. A request for url will be redirected to url + "/" if the original URL request (what you see in your browser) doesn't include a trailing slash. This is required for creating virtual directories, so that relative URLs and redirects work.


getResource

protected ResourceHandler getResource(String url)
                               throws javax.servlet.ServletException
Fetch a page based on the URL stub.

Parameters:
url - The URL stub following the site-node URL
Returns:
A ResourceHandler or null if none exists.
Throws:
javax.servlet.ServletException

addResource

protected void addResource(String url,
                           String className)
Map a page to a URL.

Parameters:
url - The URL
className - The name of the ResourceHandler class

releaseResource

public static void releaseResource(String url)
Release the page at the specified URL.

Parameters:
url - The URL

checkUserAccess

protected void checkUserAccess(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response,
                               com.arsdigita.dispatcher.RequestContext actx)
                        throws javax.servlet.ServletException
Deprecated. subclasses of ResourceHandler should check the permissions directly on the ContentItem being served. This method currently acts as a no-op

Verify that the user is logged in and is able to view the page. Subclasses can override this method if they need to, but should always be sure to call super.checkUserAccess(...)

Parameters:
request - The HTTP request
response - The HTTP response
actx - The request context
Throws:
javax.servlet.ServletException

redirectToLoginPage

protected void redirectToLoginPage(javax.servlet.http.HttpServletRequest req,
                                   javax.servlet.http.HttpServletResponse resp)
                            throws javax.servlet.ServletException
Redirects the client to the login page, setting the return url to the current request URI.

Throws:
javax.servlet.ServletException - If there is an exception thrown while trying to redirect, wrap that exception in a ServletException

newParseConfigHandler

protected org.xml.sax.helpers.DefaultHandler newParseConfigHandler(Map map)
Expirimental Returns a SAX event handler object for setting up a MapDispatcher using an XML config file.

Parameters:
map - A map to configure
Returns:
a SAX DefaultHandler object for handling SAX events


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2352 UTC