Example usage for org.apache.wicket.protocol.http WebApplication getComponentInstantiationListeners

List of usage examples for org.apache.wicket.protocol.http WebApplication getComponentInstantiationListeners

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http WebApplication getComponentInstantiationListeners.

Prototype

public final ComponentInstantiationListenerCollection getComponentInstantiationListeners() 

Source Link

Usage

From source file:de.alpharogroup.wicket.base.util.application.ApplicationExtensions.java

License:Apache License

/**
 * Initializes the given WebApplication with the Spring framework.
 *
 * @param application/*w w  w .  j  a va  2s  .c  o m*/
 *            the WebApplication
 */
public static void initializeSpring(final WebApplication application) {
    application.getComponentInstantiationListeners().add(new SpringComponentInjector(application));
}

From source file:org.jaulp.wicket.base.util.application.ApplicationUtils.java

License:Apache License

/**
 * Initializes the given WebApplication with the Spring framework.
 *
 * @param application/*from w  w w . j  ava2s  . c om*/
 *            the WebApplication
 */
public static void initializeSpring(WebApplication application) {
    application.getComponentInstantiationListeners().add(new SpringComponentInjector(application));
}

From source file:org.seasar.wicket.S2WicketFilter.java

License:Apache License

private void initInternal(final boolean isServlet, FilterConfig filterConfig) throws ServletException {
    // ????????????
    destroy();//from   w  w  w  .ja  va 2 s  .c  om

    // ???
    configuration = getInitParameter(filterConfig, "configuration", "development").toUpperCase();
    configPath = getInitParameter(filterConfig, "configPath", "app.dicon");
    debug = getInitParameter(filterConfig, "debug", null);
    reloadingClassPattern = getInitParameter(filterConfig, "reloadingClassPattern", null);
    useReloadingClassLoader = RuntimeConfigurationType.DEVELOPMENT.name().equalsIgnoreCase(configuration)
            && reloadingClassPattern != null;

    if (logger.isInfoEnabled()) {
        logger.info("[config] configuration='{}'", configuration);
        logger.info("[config] configPath='{}'", configPath);
        logger.info("[config] debug='{}'", debug);
        logger.info("[config] reloadingClassPattern='{}'", reloadingClassPattern);
    }

    if (RuntimeConfigurationType.DEVELOPMENT == RuntimeConfigurationType.valueOf(configuration)
            && reloadingClassPattern != null) {
        ReloadingClassLoader.getPatterns().clear();
        // ??????????
        // ???????????
        for (String classPattern : reloadingClassPattern.split(",")) {
            if (!classPattern.startsWith("-")) {
                ReloadingClassLoader.includePattern(classPattern);
            } else {
                ReloadingClassLoader.excludePattern(classPattern.substring(1));
            }
        }
        for (URL str : ReloadingClassLoader.getLocations()) {
            logger.info("[classpath] {}", str);
        }
        for (String str : ReloadingClassLoader.getPatterns()) {
            logger.info("[pattern] {}", str);
        }
    }

    ComponentDeployerFactory.setProvider(new ExternalComponentDeployerProvider());
    S2Container s2container = S2ContainerFactory.create(configPath, getClassLoader());
    s2container.setExternalContext(new HttpServletExternalContext());
    s2container.setExternalContextComponentDefRegister(new HttpServletExternalContextComponentDefRegister());
    s2container.getExternalContext().setApplication(filterConfig.getServletContext());
    s2container.init();
    SingletonS2ContainerFactory.setContainer(s2container);

    if (SmartDeployUtil.isHotdeployMode(SingletonS2ContainerFactory.getContainer())) {
        throw new ServletException("S2Wicket does not support HOT deploy mode.");
    }

    // Application???getHomePage()??????
    // ????????????

    super.init(isServlet, filterConfig);

    // ???WebApplication?????????
    WebApplication webApplication = (WebApplication) Application.get(filterConfig.getFilterName());
    webApplication.getComponentInstantiationListeners().add(new ComponentInjectionListener());
    applicationConfigType = webApplication.getConfigurationType();
    applicationEncoding = webApplication.getRequestCycleSettings().getResponseRequestEncoding();

    if (RuntimeConfigurationType.DEVELOPMENT == RuntimeConfigurationType.valueOf(configuration)) {
        webApplication.getFrameworkSettings()
                .setSerializer(new ReloadingJavaSerializer(webApplication.getApplicationKey()));
        if (debug != null) {
            webApplication.mountPage(debug, S2DebugPage.class);
        }
    }
}

From source file:sk.drunkenpanda.leaflet.Leaflet.java

License:Apache License

/**
 * Install Leaflet with given settings to application.
 * If application already has Leaflet installed, it ignores new settings.
 *
 * @param application application, which Leaflet should be bounded to.
 * @param settings custom settings, which are used to initialized library
 * @throws IllegalArgumentException if application is {@code null}.
 *///from w w w  . ja  va2s  .  c o m
public static void install(WebApplication application, LeafletSettings settings) {
    // install Leaflet.js with given configuration
    Args.notNull(application, "application");

    if (application.getMetaData(LEAFLET_SETTINGS_KEY) == null) {
        LeafletSettings settingsOrDefault = settings != null ? settings : new DefaultLeafletSettings();
        application.setMetaData(LEAFLET_SETTINGS_KEY, settingsOrDefault);

        if (settingsOrDefault.autoAppendResources()) {
            application.getComponentInstantiationListeners().add(new LeafletResourceAppender());
        }

        if (settingsOrDefault.useWebJars()) {
            WicketWebjars.install(application);
        }
    }
}