JSF-Spring

de.mindmatters.faces.spring.context.servlet
Class LifecycleExecutor

java.lang.Object
  extended by de.mindmatters.faces.spring.context.servlet.LifecycleExecutor
All Implemented Interfaces:
HandlerAdapter

public class LifecycleExecutor
extends java.lang.Object
implements HandlerAdapter

HandlerAdapter implementation that delegates it's work to any given arbitrary HandlerAdapter and integrates it into the workflow of the request processing of the underliying JSF implementation.

Author:
Andreas Kuhrwahl
See Also:
Lifecycle.execute(FacesContext)

Field Summary
protected  org.apache.commons.logging.Log log
          For logging.
 
Constructor Summary
LifecycleExecutor(HandlerAdapter internalHandlerAdapter)
          Creates a LifecycleExecutor with the given internal HandlerAdapter internalHandlerAdapter.
LifecycleExecutor(HandlerAdapter internalHandlerAdapter, java.lang.String lifecycleId)
          Creates a LifecycleExecutor with the given internal HandlerAdapter internalHandlerAdapter.
 
Method Summary
protected static void bindHandler(FacesContext context, java.lang.Object handler)
          Associate the given Handler with the current thread.
static java.lang.Object getHandler(FacesContext context)
          Returns the current Handler from the current thread.
 long getLastModified(javax.servlet.http.HttpServletRequest request, java.lang.Object handler)
          Same contract as for HttpServlet's getLastModified method.
 ModelAndView handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)
          Use the given handler to handle this request.
 boolean supports(java.lang.Object handler)
          Given a handler instance, return whether or not this HandlerAdapter can support it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
For logging.

Constructor Detail

LifecycleExecutor

public LifecycleExecutor(HandlerAdapter internalHandlerAdapter)
Creates a LifecycleExecutor with the given internal HandlerAdapter internalHandlerAdapter.

Parameters:
internalHandlerAdapter - The arbitrary HandlerAdapter which is decorated an integrated in the faces lifecycle

LifecycleExecutor

public LifecycleExecutor(HandlerAdapter internalHandlerAdapter,
                         java.lang.String lifecycleId)
Creates a LifecycleExecutor with the given internal HandlerAdapter internalHandlerAdapter.

Parameters:
internalHandlerAdapter - The arbitrary HandlerAdapter which is decorated an integrated in the faces lifecycle
lifecycleId - the lifecycle id for identifying the proper lifecycle this adapter will use for integration purposes
Method Detail

bindHandler

protected static void bindHandler(FacesContext context,
                                  java.lang.Object handler)
Associate the given Handler with the current thread.

Parameters:
context - FacesContext for the current request
handler - the current Handler

getHandler

public static java.lang.Object getHandler(FacesContext context)
Returns the current Handler from the current thread.

Parameters:
context - FacesContext for the current request
Returns:
the current Handler

supports

public final boolean supports(java.lang.Object handler)
Given a handler instance, return whether or not this HandlerAdapter can support it. Typical HandlerAdapters will base the decision on the handler type. HandlerAdapters will usually only support one handler type each.

A typical implementation:

return (handler instanceof MyHandler);

Specified by:
supports in interface HandlerAdapter
Parameters:
handler - handler object to check
Returns:
whether or not this object can use the given handler

getLastModified

public final long getLastModified(javax.servlet.http.HttpServletRequest request,
                                  java.lang.Object handler)
Same contract as for HttpServlet's getLastModified method. Can simply return -1 if there's no support in the handler class.

Specified by:
getLastModified in interface HandlerAdapter
Parameters:
request - current HTTP request
handler - handler to use
Returns:
the lastModified value for the given handler
See Also:
HttpServlet.getLastModified(javax.servlet.http.HttpServletRequest), LastModified.getLastModified(javax.servlet.http.HttpServletRequest)

handle

public ModelAndView handle(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response,
                           java.lang.Object handler)
                    throws java.lang.Exception
Use the given handler to handle this request. The workflow that is required may vary widely.

Specified by:
handle in interface HandlerAdapter
Parameters:
request - current HTTP request
response - current HTTP response
handler - handler to use. This object must have previously been passed to the supports method of this interface, which must have returned true.
Returns:
ModelAndView object with the name of the view and the required model data, or null if the request has been handled directly
Throws:
java.lang.Exception - in case of errors

JSF-Spring

Copyright © 2006 mindmatters GmbH & Co. KG