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 and Description |
---|
ChainProcessor() |
Modifier and Type | Method and Description |
---|---|
protected org.apache.commons.chain.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). |
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.
process
in interface Processor
context
- FacesContext
for the current requestresourceId
- Resource identifier used to select the appropriate response
(this will generally be a context relative path starting with "/")IOException
- if an input/output error occursNullPointerException
- if viewId
is null
protected org.apache.commons.chain.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
.
context
- FacesContext
for the current requestresourceId
- Resource identifier to be mappedprotected 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.
context
- FacesContext
for the current requestresourceId
- Resource identifier to be mappedprotected 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:
context
- FacesContext
for the current requestresourceId
- Resource identifier to be mappedprotected 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.
context
- FacesContext
for the current requestresourceId
- Resource identifier of the resource that was not foundIllegalArgumentException
- if we cannot send an HTTP responseIOException
- if an input/output error occursprotected 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.
context
- FacesContext
for the current requestresourceId
- Resource identifier of the resource that was not founde
- Server exception to be reportedjavax.faces.FacesException
- if we cannot send an HTTP responseIOException
- if an input/output error occursprotected boolean servletRequest(javax.faces.context.FacesContext context)
Return true
if we are processing a servlet request (as
opposed to a portlet request).
context
- FacesContext
for the current requestCopyright © 2004-2013 Apache Software Foundation. All Rights Reserved.