comparison src/org/eclipse/jetty/server/handler/ContextHandler.java @ 993:d9d95acded81

remove ScopedHandler
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 18 Oct 2016 15:54:54 -0600
parents 0608a6664bee
children 4e9d373bf6e9
comparison
equal deleted inserted replaced
992:0608a6664bee 993:d9d95acded81
91 * The maximum size of a form that can be processed by this context is controlled by the system properties org.eclipse.jetty.server.Request.maxFormKeys 91 * The maximum size of a form that can be processed by this context is controlled by the system properties org.eclipse.jetty.server.Request.maxFormKeys
92 * and org.eclipse.jetty.server.Request.maxFormContentSize. These can also be configured with {@link #setMaxFormContentSize(int)} and {@link #setMaxFormKeys(int)} 92 * and org.eclipse.jetty.server.Request.maxFormContentSize. These can also be configured with {@link #setMaxFormContentSize(int)} and {@link #setMaxFormKeys(int)}
93 * 93 *
94 * @org.apache.xbean.XBean description="Creates a basic HTTP context" 94 * @org.apache.xbean.XBean description="Creates a basic HTTP context"
95 */ 95 */
96 public final class ContextHandler extends ScopedHandler implements Server.Graceful 96 public final class ContextHandler extends HandlerWrapper implements Server.Graceful
97 { 97 {
98 private static final Logger LOG = LoggerFactory.getLogger(ContextHandler.class); 98 private static final Logger LOG = LoggerFactory.getLogger(ContextHandler.class);
99 99
100 private static final ThreadLocal<Context> __context = new ThreadLocal<Context>(); 100 private static final ThreadLocal<Context> __context = new ThreadLocal<Context>();
101 101
227 __context.set(old_context); 227 __context.set(old_context);
228 } 228 }
229 } 229 }
230 230
231 /* ------------------------------------------------------------ */ 231 /* ------------------------------------------------------------ */
232 public void callContextInitialized (ServletContextListener l, ServletContextEvent e)
233 {
234 l.contextInitialized(e);
235 }
236
237 /* ------------------------------------------------------------ */
238 public void callContextDestroyed (ServletContextListener l, ServletContextEvent e)
239 {
240 l.contextDestroyed(e);
241 }
242
243 /* ------------------------------------------------------------ */
244 /* 232 /*
245 * @see org.eclipse.thread.AbstractLifeCycle#doStop() 233 * @see org.eclipse.thread.AbstractLifeCycle#doStop()
246 */ 234 */
247 @Override 235 @Override
248 protected void doStop() throws Exception 236 protected void doStop() throws Exception
265 } 253 }
266 254
267 _contextAttributes.clearAttributes(); 255 _contextAttributes.clearAttributes();
268 } 256 }
269 257
270 /* ------------------------------------------------------------ */
271 /*
272 * @see org.eclipse.jetty.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
273 */
274 private boolean checkContext(final String target, final Request baseRequest, final HttpServletResponse response) throws IOException, ServletException 258 private boolean checkContext(final String target, final Request baseRequest, final HttpServletResponse response) throws IOException, ServletException
275 { 259 {
276 switch (_availability) 260 switch (_availability)
277 { 261 {
278 case __STOPPED: 262 case __STOPPED:
306 } 290 }
307 291
308 return true; 292 return true;
309 } 293 }
310 294
311 /* ------------------------------------------------------------ */
312 /**
313 * @see org.eclipse.jetty.server.handler.ScopedHandler#doScope(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest,
314 * javax.servlet.http.HttpServletResponse)
315 */
316 @Override 295 @Override
317 public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException 296 public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
318 { 297 {
319 if (LOG.isDebugEnabled()) 298 if (LOG.isDebugEnabled())
320 LOG.debug("scope {}|{}|{} @ {}",baseRequest.getContextPath(),baseRequest.getServletPath(),baseRequest.getPathInfo(),this); 299 LOG.debug("scope {}|{}|{} @ {}",baseRequest.getContextPath(),baseRequest.getServletPath(),baseRequest.getPathInfo(),this);
321 300
322 Context old_context = null; 301 Context old_context = null;
373 } 352 }
374 353
375 if (LOG.isDebugEnabled()) 354 if (LOG.isDebugEnabled())
376 LOG.debug("context={}|{}|{} @ {}",baseRequest.getContextPath(),baseRequest.getServletPath(), baseRequest.getPathInfo(),this); 355 LOG.debug("context={}|{}|{} @ {}",baseRequest.getContextPath(),baseRequest.getServletPath(), baseRequest.getPathInfo(),this);
377 356
378 // start manual inline of nextScope(target,baseRequest,request,response); 357 try
379 if (never()) 358 {
380 nextScope(target,baseRequest,request,response); 359 super.handle(target,baseRequest,request,response);
381 else if (_nextScope != null) 360 }
382 _nextScope.doScope(target,baseRequest,request,response); 361 catch (HttpException e)
383 else if (_outerScope != null) 362 {
384 _outerScope.doHandle(target,baseRequest,request,response); 363 LOG.debug("",e);
385 else 364 baseRequest.setHandled(true);
386 doHandle(target,baseRequest,request,response); 365 response.sendError(e.getStatus(),e.getReason());
387 // end manual inline (pathentic attempt to reduce stack depth) 366 }
388 } 367 }
389 finally 368 finally
390 { 369 {
391 if (old_context != _scontext) 370 if (old_context != _scontext)
392 { 371 {
395 __context.set(old_context); 374 __context.set(old_context);
396 baseRequest.setContextPath(old_context_path); 375 baseRequest.setContextPath(old_context_path);
397 baseRequest.setServletPath(old_servlet_path); 376 baseRequest.setServletPath(old_servlet_path);
398 baseRequest.setPathInfo(old_path_info); 377 baseRequest.setPathInfo(old_path_info);
399 } 378 }
400 }
401 }
402
403 /* ------------------------------------------------------------ */
404 /**
405 * @see org.eclipse.jetty.server.handler.ScopedHandler#doHandle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest,
406 * javax.servlet.http.HttpServletResponse)
407 */
408 @Override
409 public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
410 {
411 try
412 {
413 // start manual inline of nextHandle(target,baseRequest,request,response);
414 // noinspection ConstantIfStatement
415 if (never())
416 nextHandle(target,baseRequest,request,response);
417 else if (_nextScope != null && _nextScope == _handler)
418 _nextScope.doHandle(target,baseRequest,request,response);
419 else if (_handler != null)
420 _handler.handle(target,baseRequest,request,response);
421 // end manual inline
422 }
423 catch (HttpException e)
424 {
425 LOG.debug("",e);
426 baseRequest.setHandled(true);
427 response.sendError(e.getStatus(),e.getReason());
428 } 379 }
429 } 380 }
430 381
431 public void setContextPath(String contextPath) 382 public void setContextPath(String contextPath)
432 { 383 {