Search in sources :

Example 1 with RequestCycleContext

use of org.apache.wicket.request.cycle.RequestCycleContext in project wicket by apache.

the class AbstractWebSocketProcessor method createRequestCycle.

private RequestCycle createRequestCycle(WebSocketRequestMapper requestMapper, WebResponse webResponse) {
    RequestCycleContext context = new RequestCycleContext(webRequest, webResponse, requestMapper, application.getExceptionMapperProvider().get());
    RequestCycle requestCycle = application.getRequestCycleProvider().apply(context);
    requestCycle.getListeners().add(application.getRequestCycleListeners());
    requestCycle.getListeners().add(new IRequestCycleListener() {

        @Override
        public void onDetach(final RequestCycle requestCycle) {
            if (Session.exists()) {
                Session.get().getPageManager().commitRequest();
            }
        }
    });
    requestCycle.getUrlRenderer().setBaseUrl(baseUrl);
    return requestCycle;
}
Also used : IRequestCycleListener(org.apache.wicket.request.cycle.IRequestCycleListener) RequestCycleContext(org.apache.wicket.request.cycle.RequestCycleContext) RequestCycle(org.apache.wicket.request.cycle.RequestCycle)

Example 2 with RequestCycleContext

use of org.apache.wicket.request.cycle.RequestCycleContext in project wicket by apache.

the class Application method createRequestCycle.

/**
 * @param request
 * @param response
 * @return request cycle
 */
public final RequestCycle createRequestCycle(final Request request, final Response response) {
    RequestCycleContext context = new RequestCycleContext(request, response, getRootRequestMapper(), getExceptionMapperProvider().get());
    RequestCycle requestCycle = getRequestCycleProvider().apply(context);
    requestCycle.getListeners().add(requestCycleListeners);
    requestCycle.getListeners().add(new IRequestCycleListener() {

        @Override
        public void onDetach(final RequestCycle requestCycle) {
            if (Session.exists()) {
                Session.get().getPageManager().commitRequest();
            }
            if (Application.exists()) {
                IRequestLogger requestLogger = Application.get().getRequestLogger();
                if (requestLogger != null) {
                    requestLogger.requestTime((System.currentTimeMillis() - requestCycle.getStartTime()));
                }
            }
        }
    });
    return requestCycle;
}
Also used : IRequestLogger(org.apache.wicket.protocol.http.IRequestLogger) IRequestCycleListener(org.apache.wicket.request.cycle.IRequestCycleListener) RequestCycleContext(org.apache.wicket.request.cycle.RequestCycleContext) RequestCycle(org.apache.wicket.request.cycle.RequestCycle)

Example 3 with RequestCycleContext

use of org.apache.wicket.request.cycle.RequestCycleContext in project openmeetings by apache.

the class ApplicationHelper method ensureApplication.

public static IApplication ensureApplication(Long langId) {
    IApplication a = ensureApplication();
    if (ThreadContext.getRequestCycle() == null) {
        ServletWebRequest req = new ServletWebRequest(new MockHttpServletRequest((Application) a, new MockHttpSession(a.getServletContext()), a.getServletContext()), "");
        RequestCycleContext rctx = new RequestCycleContext(req, new MockWebResponse(), a.getRootRequestMapper(), a.getExceptionMapperProvider().get());
        ThreadContext.setRequestCycle(new RequestCycle(rctx));
    }
    if (ThreadContext.getSession() == null) {
        WebSession s = WebSession.get();
        if (langId > 0) {
            ((IWebSession) s).setLanguage(langId);
        }
    }
    return a;
}
Also used : MockWebResponse(org.apache.wicket.mock.MockWebResponse) IApplication(org.apache.openmeetings.IApplication) RequestCycleContext(org.apache.wicket.request.cycle.RequestCycleContext) IWebSession(org.apache.openmeetings.IWebSession) WebSession(org.apache.wicket.protocol.http.WebSession) IWebSession(org.apache.openmeetings.IWebSession) MockHttpServletRequest(org.apache.wicket.protocol.http.mock.MockHttpServletRequest) RequestCycle(org.apache.wicket.request.cycle.RequestCycle) MockHttpSession(org.apache.wicket.protocol.http.mock.MockHttpSession) ServletWebRequest(org.apache.wicket.protocol.http.servlet.ServletWebRequest) IApplication(org.apache.openmeetings.IApplication) Application(org.apache.wicket.Application) WebApplication(org.apache.wicket.protocol.http.WebApplication)

Aggregations

RequestCycle (org.apache.wicket.request.cycle.RequestCycle)3 RequestCycleContext (org.apache.wicket.request.cycle.RequestCycleContext)3 IRequestCycleListener (org.apache.wicket.request.cycle.IRequestCycleListener)2 IApplication (org.apache.openmeetings.IApplication)1 IWebSession (org.apache.openmeetings.IWebSession)1 Application (org.apache.wicket.Application)1 MockWebResponse (org.apache.wicket.mock.MockWebResponse)1 IRequestLogger (org.apache.wicket.protocol.http.IRequestLogger)1 WebApplication (org.apache.wicket.protocol.http.WebApplication)1 WebSession (org.apache.wicket.protocol.http.WebSession)1 MockHttpServletRequest (org.apache.wicket.protocol.http.mock.MockHttpServletRequest)1 MockHttpSession (org.apache.wicket.protocol.http.mock.MockHttpSession)1 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)1