Example usage for org.apache.wicket Application getComponentInstantiationListeners

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

Introduction

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

Prototype

public final ComponentInstantiationListenerCollection getComponentInstantiationListeners() 

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 w w w  .j  av  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);
}

From source file:com.github.wicket.autowire.AutoWire.java

License:Apache License

public static void install(final Application application) {
    final AutoWire instance = new AutoWire();
    application.getComponentInitializationListeners().add(instance);
    application.getComponentInstantiationListeners().add(instance);
}

From source file:org.wicketstuff.dashboard.DashboardContextInitializer.java

License:Apache License

@Override
public void init(Application application) {
    // create dashboard context
    DashboardContext dashboardContext = new DashboardContext();

    // store dashboard context in application
    application.setMetaData(DASHBOARD_CONTEXT_KEY, dashboardContext);

    // add dashboard context injector
    DashboardContextInjector dashboardContextInjector = new DashboardContextInjector(dashboardContext);
    application.getComponentInstantiationListeners().add(dashboardContextInjector);
}

From source file:ro.fortsoft.wicket.plugin.PluginManagerInitializer.java

License:Apache License

@Override
public void init(Application application) {
    pluginManager = createPluginManager(application);
    if (pluginManager == null) {
        throw new WicketRuntimeException("Plugin manager cannot be null");
    }//ww  w .  j av  a 2 s.c  om

    log.debug("Created plugin manager {}", pluginManager);

    // load plugins        
    pluginManager.loadPlugins();

    // init plugins
    List<PluginWrapper> resolvedPlugins = pluginManager.getResolvedPlugins();
    for (PluginWrapper plugin : resolvedPlugins) {
        if (plugin.getPlugin() instanceof WicketPlugin) {
            ((WicketPlugin) plugin.getPlugin()).init(application);
        }
    }

    // start plugins
    pluginManager.startPlugins();

    // set class resolver
    CompoundClassResolver classResolver = new CompoundClassResolver();
    List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins();
    for (PluginWrapper plugin : startedPlugins) {
        classResolver.add(new PluginClassResolver(plugin));
    }
    application.getApplicationSettings().setClassResolver(classResolver);

    // store plugin manager in application
    application.setMetaData(PLUGIN_MANAGER_KEY, pluginManager);

    // add PluginComponentInjector
    application.getComponentInstantiationListeners().add(new PluginComponentInjector(application));
}