Example usage for org.apache.wicket Application getBehaviorInstantiationListeners

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

Introduction

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

Prototype

public final BehaviorInstantiationListenerCollection getBehaviorInstantiationListeners() 

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");
        }/*from www .  j  a v  a 2  s. com*/
    } 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);
}