Search in sources :

Example 1 with BiocacheLabelLocator

use of zk.extra.BiocacheLabelLocator in project spatial-portal by AtlasOfLivingAustralia.

the class ApplicationInit method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent sce) {
    // first log message can come from a log4j instance without substituting
    // variables, just so we know we at least got this far...
    LOGGER.debug("================[WEB PORTAL APPLICATION INIT]================");
    // now the spring context gets loaded by superclass...
    super.contextInitialized(sce);
    ServletContext servletContext = sce.getServletContext();
    WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    /* configurationLoader is a daemon thread that runs for the duration
             * of the application - it is set to periodically reload the configuration.
             * We store the both the thread and the runnable in application scope so
             * we can kill the thread cleanly
             */
    ConfigurationLoaderStage1 configurationLoader = context.getBean(ConfigurationLoaderStage1.class);
    configurationLoader.setServletContext(servletContext);
    servletContext.setAttribute(CONFIGURATION_LOADER_ATTRIBUTE, configurationLoader);
    Thread configurationLoaderThread = new Thread(configurationLoader);
    // set the name for debugging purposes.  We tostring the thread object
    // so that the name will contain the memory address so we can distinguish
    // between diferent instances of the same thread should this happen.
    configurationLoaderThread.setName("ConfigurationLoader-instance-" + configurationLoaderThread.toString());
    servletContext.setAttribute(CONFIGURATION_LOADER_THREAD_ATTRIBUTE, configurationLoaderThread);
    // start the tread running and return control immediately
    configurationLoaderThread.start();
    //NC 2013-11-26: initialise the ZK Labels to include biocache WS i18n version. 
    LOGGER.debug("REGISTERING Biocache Labeller...");
    Labels.register(new BiocacheLabelLocator());
    LOGGER.debug("* APPLICATION INIT: complete");
}
Also used : BiocacheLabelLocator(zk.extra.BiocacheLabelLocator) ConfigurationLoaderStage1(au.org.emii.portal.config.ConfigurationLoaderStage1) ServletContext(javax.servlet.ServletContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Aggregations

ConfigurationLoaderStage1 (au.org.emii.portal.config.ConfigurationLoaderStage1)1 ServletContext (javax.servlet.ServletContext)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1 BiocacheLabelLocator (zk.extra.BiocacheLabelLocator)1