org.kohsuke.stapler
Class Dispatcher

java.lang.Object
  extended by org.kohsuke.stapler.Dispatcher

public abstract class Dispatcher
extends java.lang.Object

Controls the dispatching of incoming HTTP requests.

Author:
Kohsuke Kawaguchi

Field Summary
static boolean TRACE
          This flag will activate the evaluation trace.
static boolean TRACE_PER_REQUEST
          This flag will activate the per-request evaluation trace for requests that have X-Stapler-Trace set to "true".
 
Constructor Summary
Dispatcher()
           
 
Method Summary
abstract  boolean dispatch(RequestImpl req, ResponseImpl rsp, java.lang.Object node)
          Trys to handle the given request and returns true if it succeeds.
static boolean isTraceEnabled(StaplerRequest req)
          Checks if tracing is enabled for the given request.
abstract  java.lang.String toString()
          Diagnostic string that explains this dispatch rule.
static void trace(StaplerRequest req, StaplerResponse rsp, java.lang.String msg)
           
static void trace(StaplerRequest req, StaplerResponse rsp, java.lang.String msg, java.lang.Object... args)
           
static boolean traceable()
           
static void traceEval(StaplerRequest req, StaplerResponse rsp, java.lang.Object node)
           
static void traceEval(StaplerRequest req, StaplerResponse rsp, java.lang.Object node, java.lang.String expression)
           
static void traceEval(StaplerRequest req, StaplerResponse rsp, java.lang.Object node, java.lang.String prefix, java.lang.String suffix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRACE

public static boolean TRACE
This flag will activate the evaluation trace. It adds the evaluation process as HTTP headers, and when the evaluation failed, special diagnostic 404 page will be rendered. Useful for developer assistance.


TRACE_PER_REQUEST

public static boolean TRACE_PER_REQUEST
This flag will activate the per-request evaluation trace for requests that have X-Stapler-Trace set to "true". It adds the evaluation process as HTTP headers, and when the evaluation failed, special diagnostic 404 page will be rendered. Useful for developer assistance.

Constructor Detail

Dispatcher

public Dispatcher()
Method Detail

dispatch

public abstract boolean dispatch(RequestImpl req,
                                 ResponseImpl rsp,
                                 java.lang.Object node)
                          throws java.io.IOException,
                                 javax.servlet.ServletException,
                                 java.lang.IllegalAccessException,
                                 java.lang.reflect.InvocationTargetException
Trys to handle the given request and returns true if it succeeds. Otherwise false.

We have a few known strategies for handling requests (for example, one is to try to treat the request as JSP invocation, another might be try getXXX(), etc) So we use a list of Dispatcher and try them one by one until someone returns true.

Throws:
java.io.IOException
javax.servlet.ServletException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

toString

public abstract java.lang.String toString()
Diagnostic string that explains this dispatch rule.

Overrides:
toString in class java.lang.Object

traceable

public static boolean traceable()

traceEval

public static void traceEval(StaplerRequest req,
                             StaplerResponse rsp,
                             java.lang.Object node)

traceEval

public static void traceEval(StaplerRequest req,
                             StaplerResponse rsp,
                             java.lang.Object node,
                             java.lang.String prefix,
                             java.lang.String suffix)

traceEval

public static void traceEval(StaplerRequest req,
                             StaplerResponse rsp,
                             java.lang.Object node,
                             java.lang.String expression)

trace

public static void trace(StaplerRequest req,
                         StaplerResponse rsp,
                         java.lang.String msg,
                         java.lang.Object... args)

trace

public static void trace(StaplerRequest req,
                         StaplerResponse rsp,
                         java.lang.String msg)

isTraceEnabled

public static boolean isTraceEnabled(StaplerRequest req)
Checks if tracing is enabled for the given request. Tracing can be enabled globally with the "stapler.trace=true" system property. Tracing can be enabled per-request by setting "stapler.trace.per-request=true" and sending an "X-Stapler-Trace" header set to "true" with the request.



Copyright © 2011. All Rights Reserved.