Search in sources :

Example 1 with IRequestCycleListener

use of org.apache.wicket.request.cycle.IRequestCycleListener 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 IRequestCycleListener

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

the class WebSocketTesterRequestCycleListenerTest method before.

@Before
public void before() {
    tester = new WicketTester();
    tester.getApplication().getRequestCycleListeners().add(new IRequestCycleListener() {

        @Override
        public void onBeginRequest(RequestCycle cycle) {
            beginRequestCalled.set(true);
        }

        @Override
        public void onEndRequest(RequestCycle cycle) {
            endRequestCalled.set(true);
        }

        @Override
        public void onDetach(RequestCycle cycle) {
            detachCalled.set(true);
        }
    });
}
Also used : IRequestCycleListener(org.apache.wicket.request.cycle.IRequestCycleListener) RequestCycle(org.apache.wicket.request.cycle.RequestCycle) WicketTester(org.apache.wicket.util.tester.WicketTester) Before(org.junit.Before)

Example 3 with IRequestCycleListener

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

the class ConversationPropagator method onDetach.

@Override
public void onDetach(RequestCycle cycle) {
    Conversation conversation = getConversation(cycle);
    if (conversation != null) {
        logger.debug("Deactivating conversation {}", conversation.getId());
        for (IRequestCycleListener listener : application.getRequestCycleListeners()) {
            if (listener instanceof ICdiAwareRequestCycleListener) {
                ((ICdiAwareRequestCycleListener) listener).onBeforeConversationDeactivated(cycle);
            }
        }
        container.deactivateConversationalContext(cycle);
        cycle.setMetaData(CONVERSATION_STARTED_KEY, null);
    }
}
Also used : IRequestCycleListener(org.apache.wicket.request.cycle.IRequestCycleListener) Conversation(javax.enterprise.context.Conversation)

Example 4 with IRequestCycleListener

use of org.apache.wicket.request.cycle.IRequestCycleListener 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)

Aggregations

IRequestCycleListener (org.apache.wicket.request.cycle.IRequestCycleListener)4 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)3 RequestCycleContext (org.apache.wicket.request.cycle.RequestCycleContext)2 Conversation (javax.enterprise.context.Conversation)1 IRequestLogger (org.apache.wicket.protocol.http.IRequestLogger)1 WicketTester (org.apache.wicket.util.tester.WicketTester)1 Before (org.junit.Before)1