org.kohsuke.stapler
Class Stapler

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.kohsuke.stapler.Stapler
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class Stapler
extends javax.servlet.http.HttpServlet

Maps an HTTP request to a method call / JSP invocation against a model object by evaluating the request URL in a EL-ish way.

This servlet should be used as the default servlet.

Author:
Kohsuke Kawaguchi
See Also:
Serialized Form

Constructor Summary
Stapler()
           
 
Method Summary
static StaplerRequest getCurrentRequest()
          Gets the current StaplerRequest that the calling thread is associated with.
static StaplerResponse getCurrentResponse()
          Gets the current StaplerResponse that the calling thread is associated with.
static java.lang.String getViewURL(java.lang.Class clazz, java.lang.String jspName)
          Gets the URL (e.g., "/WEB-INF/side-files/fully/qualified/class/name/jspName") from a class and the JSP name.
 void init(javax.servlet.ServletConfig servletConfig)
           
 void invoke(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp, java.lang.Object root, java.lang.String url)
          Performs stapler processing on the given root object and request URL.
protected  void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp)
           
static void setExpressionFactory(javax.servlet.ServletContextEvent event, org.apache.commons.jelly.expression.ExpressionFactory factory)
          Sets the Jelly ExpressionFactory to be used to parse views.
static void setRoot(javax.servlet.ServletContextEvent event, java.lang.Object rootApp)
          Sets the specified object as the root of the web application.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, 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
 

Constructor Detail

Stapler

public Stapler()
Method Detail

init

public void init(javax.servlet.ServletConfig servletConfig)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

service

protected void service(javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse rsp)
                throws javax.servlet.ServletException,
                       java.io.IOException
Overrides:
service in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

invoke

public void invoke(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse rsp,
                   java.lang.Object root,
                   java.lang.String url)
            throws java.io.IOException,
                   javax.servlet.ServletException
Performs stapler processing on the given root object and request URL.

Throws:
java.io.IOException
javax.servlet.ServletException

getViewURL

public static java.lang.String getViewURL(java.lang.Class clazz,
                                          java.lang.String jspName)
Gets the URL (e.g., "/WEB-INF/side-files/fully/qualified/class/name/jspName") from a class and the JSP name.


setRoot

public static void setRoot(javax.servlet.ServletContextEvent event,
                           java.lang.Object rootApp)
Sets the specified object as the root of the web application.

This method should be invoked from your implementation of ServletContextListener.contextInitialized(ServletContextEvent).

This is just a convenience method to invoke servletContext.setAttribute("app",rootApp).

The root object is bound to the URL '/' and used to resolve all the requests to this web application.


setExpressionFactory

public static void setExpressionFactory(javax.servlet.ServletContextEvent event,
                                        org.apache.commons.jelly.expression.ExpressionFactory factory)
Sets the Jelly ExpressionFactory to be used to parse views.

This method should be invoked from your implementation of ServletContextListener.contextInitialized(ServletContextEvent).

Once views are parsed, they won't be re-parsed just because you called this method to override the expression factory.

The primary use case of this feature is to customize the behavior of JEXL evaluation.


getCurrentRequest

public static StaplerRequest getCurrentRequest()
Gets the current StaplerRequest that the calling thread is associated with.


getCurrentResponse

public static StaplerResponse getCurrentResponse()
Gets the current StaplerResponse that the calling thread is associated with.



Copyright © 2007. All Rights Reserved.