org.apache.shale.remoting.impl
Class ChainProcessor

java.lang.Object
  extended by org.apache.shale.remoting.impl.ChainProcessor
All Implemented Interfaces:
Processor

public class ChainProcessor
extends Object
implements Processor

Implementation of Processor which maps a resource identifier to the name of a Commons Chain command or chain, in an appropriate catalog. The command or chain that is executed is passed an appropriate Context object, and it will also have access to the current JavaServer Faces state by calling FacesContext.getCurrentInstance().


Constructor Summary
ChainProcessor()
           
 
Method Summary
protected  Context createContext(javax.faces.context.FacesContext context, String resourceId)
          Create and return an appropriate Context instance to be passed to the command or chain that is executed.
protected  String mapCatalog(javax.faces.context.FacesContext context, String resourceId)
          Map the specified resource identifier to the name of a Commons Chain Catalog from which the command or chain instance will be acquired.
protected  String mapCommand(javax.faces.context.FacesContext context, String resourceId)
          Map the specified resource identifier to the name of a Commons Chain Command or Chain, which will be acquired from a mapped Catalog.
 void process(javax.faces.context.FacesContext context, String resourceId)
          Map the specified resource identifier to an appropriate Commons Chain command or chain, in an appropriate catalog.
protected  void sendNotFound(javax.faces.context.FacesContext context, String resourceId)
          Send a "not found" HTTP response, if possible.
protected  void sendServerError(javax.faces.context.FacesContext context, String resourceId, Exception e)
          Send a "server error" HTTP response, if possible.
protected  boolean servletRequest(javax.faces.context.FacesContext context)
          Return true if we are processing a servlet request (as opposed to a portlet request).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChainProcessor

public ChainProcessor()
Method Detail

process

public void process(javax.faces.context.FacesContext context,
                    String resourceId)
             throws IOException

Map the specified resource identifier to an appropriate Commons Chain command or chain, in an appropriate catalog. Construct an appropriate Context object, and execute the specified command or chain, to which we delegate responsibility for creating the response for the current request. Call FacesContext.responseComplete() to tell JavaServer Faces that the entire response has already been created.

Specified by:
process in interface Processor
Parameters:
context - FacesContext for the current request
resourceId - Resource identifier used to select the appropriate response (this will generally be a context relative path starting with "/")
Throws:
IOException - if an input/output error occurs
NullPointerException - if viewId is null

createContext

protected Context createContext(javax.faces.context.FacesContext context,
                                String resourceId)

Create and return an appropriate Context instance to be passed to the command or chain that is executed.

The default algorithm constructs and returns an instance of ChainContext that wraps the specified FacesContext.

Parameters:
context - FacesContext for the current request
resourceId - Resource identifier to be mapped

mapCatalog

protected String mapCatalog(javax.faces.context.FacesContext context,
                            String resourceId)

Map the specified resource identifier to the name of a Commons Chain Catalog from which the command or chain instance will be acquired.

The default implementation returns remoting unconditionally.

Parameters:
context - FacesContext for the current request
resourceId - Resource identifier to be mapped

mapCommand

protected String mapCommand(javax.faces.context.FacesContext context,
                            String resourceId)

Map the specified resource identifier to the name of a Commons Chain Command or Chain, which will be acquired from a mapped Catalog.

The default algorithm performs this conversion as follows:

Parameters:
context - FacesContext for the current request
resourceId - Resource identifier to be mapped

sendNotFound

protected void sendNotFound(javax.faces.context.FacesContext context,
                            String resourceId)
                     throws IOException

Send a "not found" HTTP response, if possible. Otherwise, throw an IllegalArgumentException that will ripple out.

Parameters:
context - FacesContext for the current request
resourceId - Resource identifier of the resource that was not found
Throws:
IllegalArgumentException - if we cannot send an HTTP response
IOException - if an input/output error occurs

sendServerError

protected void sendServerError(javax.faces.context.FacesContext context,
                               String resourceId,
                               Exception e)
                        throws IOException

Send a "server error" HTTP response, if possible. Otherwise, throw a FacesException that will ripple out.

Parameters:
context - FacesContext for the current request
resourceId - Resource identifier of the resource that was not found
e - Server exception to be reported
Throws:
javax.faces.FacesException - if we cannot send an HTTP response
IOException - if an input/output error occurs

servletRequest

protected boolean servletRequest(javax.faces.context.FacesContext context)

Return true if we are processing a servlet request (as opposed to a portlet request).

Parameters:
context - FacesContext for the current request


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.