webContextBuilder.disengageThread();
if (webContextBuilder != null) webContextBuilder.engageThread(container, null, null); webContextBuilder.disengageThread();
HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); WebContextFactory.WebContextBuilder contextBuilder = container.getBean(WebContextFactory.WebContextBuilder.class); contextBuilder.engageThread(container, request, response); contextBuilder.disengageThread();
/** * Find all the containers that have been registered, and check all the * contained beans for ones that implement {@link ServletContextListener} * and pass the {@link ServletContextListener#contextDestroyed} event on. * @param ev The event object to pass on * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) */ public void contextDestroyed(ServletContextEvent ev) { List<Container> containers = StartupUtil.getAllPublishedContainers(ev.getServletContext()); if (containers.isEmpty()) { log.debug("No containers to shutdown"); return; } for (Container container : containers) { WebContextBuilder webContextBuilder = container.getBean(WebContextBuilder.class); if (webContextBuilder != null) { webContextBuilder.engageThread(container, null, null); } container.destroy(); if (webContextBuilder != null) { webContextBuilder.disengageThread(); } } }
webContextBuilder.engageThread(container, (HttpServletRequest) request, (HttpServletResponse) response); chain.doFilter(request, response); webContextBuilder.disengageThread();
/** * Handles all request to this controller. <br/> * It delegates to the <code>UrlProcessor</code> and also takes case of setting and unsetting of the * current <code>WebContext</code>. * @param request the request to handle * @param response the response to handle * @throws Exception in case handling of the request fails unexpectedly * @see org.directwebremoting.WebContext */ @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { try { // set up the web context and delegate to the processor webContextBuilder.engageThread(container, request, response); UrlProcessor processor = container.getBean(UrlProcessor.class); processor.handle(request, response); } finally { webContextBuilder.disengageThread(); } // return null to inform the dispatcher servlet the request has already been handled return null; }
@Override public void destroy() { webContextBuilder = container.getBean(WebContextBuilder.class); if (webContextBuilder != null) { webContextBuilder.engageThread(container, null, null); } container.destroy(); if (webContextBuilder != null) { webContextBuilder.disengageThread(); } super.destroy(); }
/** * Clean up the current thread when {@link #outOfContainerInit()} has been * called. * @param container The container created by {@link #outOfContainerInit()}. */ public static void outOfContainerDestroy(Container container) { WebContextBuilder webContextBuilder = container.getBean(WebContextBuilder.class); if (webContextBuilder != null) { webContextBuilder.disengageThread(); } }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { webContextBuilder.engageThread(container, request, response); UrlProcessor processor = container.getBean(UrlProcessor.class); processor.handle(request, response); } finally { webContextBuilder.disengageThread(); } }
/** * Accessor for the current {@link WebContext}. * @return The current WebContext or null if the current thread was not * started by DWR. */ public static WebContext get() { if (builder == null) { return null; } return builder.get(); }
/** * */ public static void engageThread() { webContextBuilder.engageThread(container, null, null); }
public void destroy() throws Exception { if (webContextBuilder != null) { webContextBuilder.engageThread(container, null, null); } container.destroy(); if (webContextBuilder != null) { webContextBuilder.disengageThread(); } }
/** * */ public static void disengageThread() { webContextBuilder.disengageThread(); }