/** * * @param requestCycle */ private static void set(RequestCycle requestCycle) { ThreadContext.setRequestCycle(requestCycle); }
/** * * @param requestCycle */ private static void set(RequestCycle requestCycle) { ThreadContext.setRequestCycle(requestCycle); }
/** * @deprecated use {@link ThreadContext#setRequestCycle(RequestCycle)} * directly */ @Deprecated public static void set(RequestCycle requestCycle) { ThreadContext.setRequestCycle(null); } }
/** * @deprecated use {@link ThreadContext#setRequestCycle(RequestCycle)} * directly */ @Deprecated public static void unset(RequestCycle requestCycle) { ThreadContext.setRequestCycle(null); }
private void executeInNewThread(Runnable runnable) { OrienteerWebSession session = OrienteerWebSession.get(); OrienteerWebApplication app = OrienteerWebApplication.get(); RequestCycle requestCycle = RequestCycle.get(); new Thread(() -> { ThreadContext.setSession(session); ThreadContext.setApplication(app); ThreadContext.setRequestCycle(requestCycle); runnable.run(); }).start(); }
@Override protected boolean processRequestCycle(final RequestCycle requestCycle, final WebResponse webResponse, final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final FilterChain chain) throws IOException, ServletException { // Assume we are able to handle the request boolean res = true; ThreadContext.setRequestCycle(requestCycle); if (acceptWebSocket(httpServletRequest, httpServletResponse) || httpServletResponse.isCommitted()) { res = true; } else if (requestCycle.processRequestAndDetach() || httpServletResponse.isCommitted()) { webResponse.flush(); } else { if (chain != null) { chain.doFilter(httpServletRequest, httpServletResponse); } res = false; } return res; }
protected boolean processRequestCycle(final RequestCycle requestCycle, final WebResponse webResponse, final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final FilterChain chain) throws IOException, ServletException { // Assume we are able to handle the request boolean res = true; ThreadContext.setRequestCycle(requestCycle); if (acceptWebSocket(httpServletRequest, httpServletResponse) || httpServletResponse.isCommitted()) { res = true; } else if (requestCycle.processRequestAndDetach() || httpServletResponse.isCommitted()) { webResponse.flush(); } else { if (chain != null) { chain.doFilter(httpServletRequest, httpServletResponse); } res = false; } return res; }
@Override public CompletableFuture<Void> fetchMailsAsync(OMailSettings settings, String folderName, Consumer<Message> consumer) { OrienteerWebSession session = OrienteerWebSession.get(); OrienteerWebApplication app = OrienteerWebApplication.get(); RequestCycle requestCycle = RequestCycle.get(); return CompletableFuture.runAsync(() -> { ThreadContext.setSession(session); ThreadContext.setApplication(app); ThreadContext.setRequestCycle(requestCycle); try { fetchMails(settings, folderName, consumer); } catch (Exception ex) { LOG.error("Error during fetching mails: {}", settings, ex); } }); }
private void performTask(OSendMailTaskSessionRuntime runtime) { OrienteerWebSession session = OrienteerWebSession.get(); OrienteerWebApplication app = OrienteerWebApplication.get(); RequestCycle requestCycle = RequestCycle.get(); new Thread(() -> { ThreadContext.setSession(session); ThreadContext.setApplication(app); ThreadContext.setRequestCycle(requestCycle); DBClosure.sudoConsumer(db -> { try { sendMails(runtime); } catch (Exception ex) { LOG.error("Error occurred during perform task {}", OSendMailTask.this, ex); } finally { runtime.finish(); } }); }).start(); }
/** * Collects the html generated by rendering a page. * * @param page * supplier of the page * @return the html rendered by the panel */ public CharSequence renderPage(final Supplier<? extends Page> page) { return inThreadContext(() -> { Request request = newRequest(); BufferedWebResponse response = new BufferedWebResponse(null); RequestCycle cycle = application.createRequestCycle(request, response); ThreadContext.setRequestCycle(cycle); page.get().renderPage(); return response.getText(); }); }
/** * Collects the html generated by rendering a page. * * @param page * supplier of the page * @return the html rendered by the panel */ public CharSequence renderPage(final Supplier<? extends Page> page) { return inThreadContext(() -> { Request request = newRequest(); BufferedWebResponse response = new BufferedWebResponse(null); RequestCycle cycle = application.createRequestCycle(request, response); ThreadContext.setRequestCycle(cycle); page.get().renderPage(); return response.getText(); }); }
/** * Collects the Html generated by the rendering a page. * <p> * Important note: Must be called on a thread bound to an application's {@link ThreadContext}! * * @param pageProvider * the provider of the page class/instance and its parameters * @return the html rendered by a page * * @see ThreadContext */ public static CharSequence renderPage(final PageProvider pageProvider) { Application application = Application.get(); RequestCycle originalRequestCycle = RequestCycle.get(); BufferedWebResponse tempResponse = new BufferedWebResponse(null); RequestCycle tempRequestCycle = application .createRequestCycle(originalRequestCycle.getRequest(), tempResponse); try { ThreadContext.setRequestCycle(tempRequestCycle); pageProvider.getPageInstance().renderPage(); } finally { ThreadContext.setRequestCycle(originalRequestCycle); } return tempResponse.getText(); }
/** * Collects the Html generated by the rendering a page. * <p> * Important note: Must be called on a thread bound to an application's {@link ThreadContext}! * * @param pageProvider * the provider of the page class/instance and its parameters * @return the html rendered by a page * * @see ThreadContext */ public static CharSequence renderPage(final PageProvider pageProvider) { Application application = Application.get(); RequestCycle originalRequestCycle = RequestCycle.get(); BufferedWebResponse tempResponse = new BufferedWebResponse(null); RequestCycle tempRequestCycle = application .createRequestCycle(originalRequestCycle.getRequest(), tempResponse); try { ThreadContext.setRequestCycle(tempRequestCycle); pageProvider.getPageInstance().renderPage(); } finally { ThreadContext.setRequestCycle(originalRequestCycle); } return tempResponse.getText(); }
/** * Invoke this method in the new thread before doing something with Wicket. */ public void mock() { ThreadContext.setApplication(application); ThreadContext.setSession(session); final MockServletContext context = new MockServletContext(application, SystemUtils.JAVA_IO_TMPDIR); ThreadContext.setRequestCycle( application.createRequestCycle(new MockWebRequest( Url.parse("http://localhost/mock")) { @Override public Object getContainerRequest() { return new MockHttpServletRequest( application, new MockHttpSession(context), context); } }, new MockWebResponse()) ); } }
ThreadContext.setRequestCycle(requestCycle); ThreadContext.setRequestCycle(oldRequestCycle); ThreadContext.setSession(oldSession);
ThreadContext.setRequestCycle(requestCycle); ThreadContext.setRequestCycle(oldRequestCycle); ThreadContext.setSession(oldSession);
ThreadContext.setRequestCycle(requestCycle); ThreadContext.setRequestCycle(oldRequestCycle); ThreadContext.setSession(oldSession);
ThreadContext.setRequestCycle(webApplication.createRequestCycle(request, response));
requestCycle = application.createRequestCycle(servletWebRequest, newServletWebResponse(servletWebRequest)); ThreadContext.setRequestCycle(requestCycle);
requestCycle = application.createRequestCycle(servletWebRequest, newServletWebResponse(servletWebRequest)); ThreadContext.setRequestCycle(requestCycle);