Example usage for org.apache.wicket Application getSessionListeners

List of usage examples for org.apache.wicket Application getSessionListeners

Introduction

In this page you can find the example usage for org.apache.wicket Application getSessionListeners.

Prototype

public final SessionListenerCollection getSessionListeners() 

Source Link

Usage

From source file:com.github.javawithmarcus.wicket.cdi.CdiConfiguration.java

License:Apache License

protected synchronized void configure(String appKey, Application application, ConfigurationParameters params) {

    if (parameters.containsKey(appKey)) {
        params = parameters.get(appKey);
        if (params.isConfigured()) {
            throw new IllegalStateException("Cannot configure CdiConfiguration multiple times");
        }// w w  w  .ja  v a 2  s. c om
    } else {
        parameters.put(appKey, params);
    }
    params.getIgnoredPackages().addAll(Arrays.asList(defaultIgnoredPackages));

    RequestCycleListenerCollection listeners = new RequestCycleListenerCollection();
    application.getRequestCycleListeners().add(listeners);

    // enable conversation propagation
    if (params.getPropagation() != ConversationPropagation.NONE) {
        enablePropagation(params, application);
    }

    // enable detach event
    listeners.add(detachEventEmitter);

    // inject application instance
    if (params.isInjectApplication()) {
        nonContextualManager.postConstruct(application);
    }

    // enable injection of various framework components

    if (params.isInjectSession()) {
        application.getSessionListeners().add(sessionInjector);
    }

    if (params.isInjectComponents()) {
        application.getComponentInstantiationListeners().add(componentInjector);
    }

    if (params.isInjectBehaviors()) {
        application.getBehaviorInstantiationListeners().add(behaviorInjector);
    }

    // enable cleanup

    application.getApplicationListeners().add(new CdiShutdownCleaner(params.isInjectApplication()));

    params.setConfigured(true);
}