use of org.springframework.web.context.WebApplicationContext 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");
}
use of org.springframework.web.context.WebApplicationContext in project OpenClinica by OpenClinica.
the class XsltTriggerService method generateXsltTrigger.
public SimpleTrigger generateXsltTrigger(Scheduler scheduler, String xslFile, String xmlFile, String endFilePath, String endFile, int datasetId, ExtractPropertyBean epBean, UserAccountBean userAccountBean, String locale, int cnt, String xsltPath, String triggerGroupName) {
//Date startDateTime = new Date(System.currentTimeMillis());
String jobName = datasetId + "_" + epBean.getExportFileName()[0];
if (triggerGroupName != null)
TRIGGER_GROUP_NAME = triggerGroupName;
//WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
ApplicationContext context = null;
try {
context = (ApplicationContext) scheduler.getContext().get("applicationContext");
} catch (SchedulerException e) {
e.printStackTrace();
}
SimpleTriggerFactoryBean triggerFactoryBean = context.getBean(SimpleTriggerFactoryBean.class, xslFile, xmlFile, endFilePath, endFile, datasetId, epBean, userAccountBean, locale, cnt, xsltPath);
SimpleTrigger trigger = triggerFactoryBean.getObject();
return trigger;
}
use of org.springframework.web.context.WebApplicationContext in project Activiti by Activiti.
the class WebConfigurer method contextDestroyed.
@Override
public void contextDestroyed(ServletContextEvent sce) {
log.info("Destroying Web application");
WebApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(sce.getServletContext());
AnnotationConfigWebApplicationContext gwac = (AnnotationConfigWebApplicationContext) ac;
gwac.close();
log.debug("Web application destroyed");
}
use of org.springframework.web.context.WebApplicationContext in project Activiti by Activiti.
the class JPAWebConfigurer method contextDestroyed.
@Override
public void contextDestroyed(ServletContextEvent sce) {
log.info("Destroying Web application");
WebApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(sce.getServletContext());
AnnotationConfigWebApplicationContext gwac = (AnnotationConfigWebApplicationContext) ac;
gwac.close();
log.debug("Web application destroyed");
}
use of org.springframework.web.context.WebApplicationContext in project opennms by OpenNMS.
the class HttpRemotingWebAppIT method test.
@Test
public void test() throws Exception {
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
assertTrue(context.containsBean("serviceRegistry"));
assertTrue(context.containsBean("serviceRegistryExporter"));
ServiceRegistry registry = context.getBean("serviceRegistry", ServiceRegistry.class);
ServiceRegistryHttpInvokerServiceExporter exporter = context.getBean("serviceRegistryExporter", ServiceRegistryHttpInvokerServiceExporter.class);
assertEquals(exporter.getServiceRegistry(), registry);
assertTrue(exporter.getServiceRegistry() == registry);
}
Aggregations