List of usage examples for javax.servlet ServletContextEvent getServletContext
public ServletContext getServletContext()
From source file:eu.sisob.uma.restserver.servlets.ServletContextClass.java
@Override public void contextInitialized(ServletContextEvent arg0) { try {/*from w ww . j a v a 2 s. co m*/ TheConfig.createInstance(arg0.getServletContext().getRealPath("")); SystemManager.getInstance().setup(); } catch (Exception ex) { Logger.getLogger("error").error("System Manager has not initialized", ex); } }
From source file:fr.cls.atoll.motu.web.servlet.listener.Log4JConfigListener.java
/** * Shut down log4j, properly releasing all file locks and resetting the web app root system property. * //from ww w. j av a 2 s . c o m * @param servletContext the current ServletContext */ @Override public void contextDestroyed(ServletContextEvent sce) { sce.getServletContext().log("Shutting down log4j"); LogManager.shutdown(); }
From source file:nl.b3p.viewer.solr.SolrUpdaterListener.java
private void init(ServletContextEvent sce) { this.context = sce.getServletContext(); interval = context.getInitParameter(PARAM_SOLR_UPDATE_INTERVAL); }
From source file:org.cruxframework.crux.core.server.DevModeInitializerListener.java
/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) *//*from w w w . j a v a 2 s . c o m*/ public void contextInitialized(ServletContextEvent contextEvent) { String charset = contextEvent.getServletContext().getInitParameter(OUTPUT_CHARSET); //TODO remover isso aqui... fixar o uso em UTF-8 if (charset != null) { ViewProcessor.setOutputCharset(charset); } else { logger.error( "Missing required parameter for [DevModeInitializerListener] in web.xml: [outputCharset]."); } if (!Environment.isProduction()) { Scanners.registerScanners(new ScannerRegistrations() { @Override public boolean initializeEagerly() { return true; //We need to ensure scanners are initialized before any attempt to use any feature that requires scanning. } @Override public void doRegistrations() { DevelopmentScanners.initializeScanners(); } }); } }
From source file:cn.vlabs.umt.ui.UMTStartupListener.java
public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); PropertyConfigurator.configure(context.getRealPath("/WEB-INF/conf/log4j.properties")); String contextxml = context.getInitParameter("contextConfigLocation"); if (contextxml == null) { contextxml = "/WEB-INF/conf/UMTContext.xml"; }/*from w w w . ja va 2 s . c o m*/ //FIX the bug in linux String realpath = context.getRealPath(contextxml); if (realpath != null && realpath.startsWith("/")) { realpath = "/" + realpath; } FileSystemXmlApplicationContext factory = new FileSystemXmlApplicationContext(realpath); PathMapper mapper = (PathMapper) factory.getBean("PathMapper"); mapper.setContext(context); CreateTable createTable = (CreateTable) factory.getBean("CreateTable"); if (!createTable.isTableExist()) { createTable.createTable(); } factory.getBean("UMTCredUtil"); context.setAttribute(Attributes.APPLICATION_CONTEXT_KEY, factory); UMTContext.setFactory(factory); }
From source file:org.jasig.springframework.web.portlet.context.PortletContextLoaderListener.java
@Override public void contextInitialized(ServletContextEvent sce) { final ServletContext servletContext = sce.getServletContext(); if (servletContext.getAttribute( PortletApplicationContextUtils2.ROOT_PORTLET_APPLICATION_CONTEXT_LOADER_ATTRIBUTE) != null) { throw new IllegalStateException( "Cannot initialize root portlet ContextLoader context because there is already a root PortletContextLoader present - " + "check whether you have multiple PortletContextLoaderListener definitions in your web.xml!"); }/* w ww . j a v a 2s. c o m*/ //Register the portlet context loader with the servlet context contextLoader = new PortletContextLoader(servletContext); servletContext.setAttribute( PortletApplicationContextUtils2.ROOT_PORTLET_APPLICATION_CONTEXT_LOADER_ATTRIBUTE, contextLoader); }
From source file:com.github.glue.mvc.general.DefaultConfigListener.java
@Override public void contextDestroyed(ServletContextEvent servletContextEvent) { ServletContext servletContext = servletContextEvent.getServletContext(); servletContext.removeAttribute(CONTAINER); super.contextDestroyed(servletContextEvent); }
From source file:com.jaspersoft.jasperserver.war.util.SpringBeanServletContextPlublisher.java
public void contextInitialized(ServletContextEvent sce) { ServletContext servletContext = sce.getServletContext(); ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); String beanNamesAttr = servletContext.getInitParameter(ATTRIBUTE_BEAN_NAMES); String[] beanNames = beanNamesAttr.split("\\,"); for (int i = 0; i < beanNames.length; i++) { String beanName = beanNames[i]; Object bean = applicationContext.getBean(beanName); if (bean == null) { log.warn("Bean \"" + beanName + "\" not found"); } else {// w w w .ja v a 2s .c o m servletContext.setAttribute(beanName, bean); if (log.isDebugEnabled()) { log.debug("Bean \"" + beanName + "\" published in the application context"); } } } }
From source file:edu.cornell.mannlib.vitro.webapp.searchindex.SearchIndexerSetup.java
@Override public void contextInitialized(ServletContextEvent sce) { ctx = sce.getServletContext(); app = ApplicationUtils.instance();/*from w ww. ja v a 2 s.c o m*/ StartupStatus ss = StartupStatus.getBean(ctx); try { searchIndexer = app.getSearchIndexer(); // A change listener, wrapped so it can respond to a developer flag. listener = new IndexingChangeListener(searchIndexer); listenerWrapper = new DeveloperDisabledChangeListener(listener, Key.SEARCH_INDEX_SUPPRESS_MODEL_CHANGE_LISTENER); RDFServiceUtils.getRDFServiceFactory(ctx).registerListener(listenerWrapper); this.history = new IndexHistory(); searchIndexer.addListener(this.history); IndexController.setHistory(this.history); searchIndexer.startup(app, new ComponentStartupStatusImpl(this, ss)); ss.info(this, "Setup of search indexer completed."); } catch (RDFServiceException e) { ss.fatal(this, "Failed to register the model changed listener.", e); } }
From source file:org.mule.config.builders.DeployableMuleXmlContextListener.java
public void contextInitialized(ServletContextEvent event) { initialize(event.getServletContext()); }