Example usage for org.apache.wicket.application ReloadingClassLoader getLocations

List of usage examples for org.apache.wicket.application ReloadingClassLoader getLocations

Introduction

In this page you can find the example usage for org.apache.wicket.application ReloadingClassLoader getLocations.

Prototype

public static Set<URL> getLocations() 

Source Link

Document

Returns the list of all configured locations of directories containing class files

Usage

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

License:Apache License

private void initInternal(final boolean isServlet, FilterConfig filterConfig) throws ServletException {
    // ????????????
    destroy();/*from   ww  w  .  j  a v a 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);
        }
    }
}