Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2004-2010 Oracle Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Kohsuke Kawaguchi /
  
 
 package org.kohsuke.stapler;
 
Controls the dispatching of incoming HTTP requests.

Author(s):
Kohsuke Kawaguchi
 
 public abstract class Dispatcher {
    
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.

 
     public abstract boolean dispatch(RequestImpl reqResponseImpl rspObject node)
Diagnostic string that explains this dispatch rule.
 
     public abstract String toString();
 
 
     public static boolean traceable() {
         return  ||  || .isLoggable(.);
     }
 
     public static void traceEval(StaplerRequest reqStaplerResponse rspObject node) {
         trace(req,rsp,String.format("-> evaluate(%s%s,\"%s\")",
                 node==null?"null":'<'+node.toString()+'>',
                 node==null?"":" :"+node.getClass().getName(),
                 ((RequestImpl)req)..assembleOriginalRestOfPath()));
     }
 
     public static void traceEval(StaplerRequest reqStaplerResponse rspObject nodeString prefixString suffix) {
         trace(req,rsp,String.format("-> evaluate(%s<%s>%s,\"%s\")",
                 prefix,node,suffix,
                 ((RequestImpl)req)..assembleOriginalRestOfPath()));
     }
 
     public static void traceEval(StaplerRequest reqStaplerResponse rspObject nodeString expression) {
         trace(req,rsp,String.format("-> evaluate(<%s>.%s,\"%s\")",
                 node,expression,
                 ((RequestImpl)req)..assembleOriginalRestOfPath()));
     }
 
     public static void trace(StaplerRequest reqStaplerResponse rspString msgObject... args) {
         trace(req,rsp,String.format(msg,args));
     }
 
     public static void trace(StaplerRequest reqStaplerResponse rspString msg) {
         if(isTraceEnabled(req))
             EvaluationTrace.get(req).trace(rsp,msg);
         if(.isLoggable(.))
             .fine(msg);
     }

    
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.
 
     public static boolean isTraceEnabled(StaplerRequest req) {
         if ()
             return true;
 
         if ( && "true".equals(req.getHeader("X-Stapler-Trace")))
             return true;
 
         return false;
     }

    
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.
    public static boolean TRACE = Boolean.getBoolean("stapler.trace");

    
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.
    public static boolean TRACE_PER_REQUEST = Boolean.getBoolean("stapler.trace.per-request");
    private static final Logger LOGGER = Logger.getLogger(Dispatcher.class.getName());
New to GrepCode? Check out our FAQ X