List of usage examples for javax.servlet ServletContextEvent getServletContext
public ServletContext getServletContext()
From source file:jp.or.openid.eiwg.listener.InitListener.java
/** * Web???/*from w w w . j ava 2 s . c o m*/ * * @param contextEvent */ @Override public void contextInitialized(ServletContextEvent contextEvent) { // ? ServletContext context = contextEvent.getServletContext(); // ??DBLDAP???? // ???????? ObjectMapper mapper = new ObjectMapper(); Map<String, Object> serviceProviderConfigs = null; ArrayList<LinkedHashMap<String, Object>> resourceTypes = null; ArrayList<LinkedHashMap<String, Object>> schemas = null; ArrayList<LinkedHashMap<String, Object>> users = null; // ?(ServiceProviderConfigs.json)?? try { serviceProviderConfigs = mapper.readValue( new File(context.getRealPath("/WEB-INF/ServiceProviderConfigs.json")), new TypeReference<LinkedHashMap<String, Object>>() { }); } catch (IOException e) { e.printStackTrace(); } // (ResourceTypes.json)?? try { resourceTypes = mapper.readValue(new File(context.getRealPath("/WEB-INF/ResourceTypes.json")), new TypeReference<ArrayList<LinkedHashMap<String, Object>>>() { }); } catch (IOException e) { e.printStackTrace(); } // (Schemas.json)?? try { schemas = mapper.readValue(new File(context.getRealPath("/WEB-INF/Schemas.json")), new TypeReference<ArrayList<LinkedHashMap<String, Object>>>() { }); } catch (IOException e) { e.printStackTrace(); } // ?? try { users = mapper.readValue(new File(context.getRealPath("/WEB-INF/Users.json")), new TypeReference<ArrayList<LinkedHashMap<String, Object>>>() { }); } catch (IOException e) { e.printStackTrace(); } // ? context.setAttribute("ServiceProviderConfigs", serviceProviderConfigs); context.setAttribute("ResourceTypes", resourceTypes); context.setAttribute("Schemas", schemas); context.setAttribute("Users", users); }
From source file:org.carrot2.webapp.LogInitContextListener.java
/** * Callback hook from the application container. Initialize logging appenders * immediately or defer initialization until possible. *//*from w ww. j ava 2 s . c o m*/ public void contextInitialized(ServletContextEvent event) { final ServletContext servletContext = event.getServletContext(); if (servletContext.getAttribute(CONTEXT_ID) != null) { // Only one instance needed. return; } /* * If the container has Servlet 2.5 API, init loggers immediately. Otherwise, save * itself to the context and wait for {@link QueryProcessorServlet} to perform * deferred initialization. */ try { final Method method = ServletContext.class.getMethod("getContextPath"); final String contextPath = (String) method.invoke(servletContext); addAppenders(contextPath); } catch (RuntimeException e) { // Rethrow runtime exceptions, if any. throw e; } catch (Exception e) { /* * No servlet 2.5 API (getContextPath), save in the context for deferred * initialization. */ servletContext.setAttribute(CONTEXT_ID, this); } }
From source file:com.medlog.webservice.lifecycle.NewServletListener.java
@Override public void contextInitialized(ServletContextEvent _sce) { LOG.log(Level.INFO, String.format("$$$$$$$$ com.medlog.webservice.lifecycle.NewServletListener# %s ", _sce.getServletContext().getContextPath())); System.out.println("\ncom.medlog.webservice.lifecycle.NewServletListener.contextInitialized() ---> " + _sce.getServletContext().getServerInfo()); _sce.getServletContext().setAttribute("activeLogins", 1); }
From source file:org.exem.flamingo.web.util.ApplicationInformationDisplayContextListener.java
@Override public void contextDestroyed(ServletContextEvent servletContextEvent) { WebLogbackConfigurer.shutdownLogging(servletContextEvent.getServletContext()); }
From source file:org.toobsframework.servlet.ContextListener.java
public void contextInitialized(ServletContextEvent event) { //super.contextInitialized(event); this.contextLoader = createContextLoader(); webApplicationContext = this.contextLoader.initWebApplicationContext(event.getServletContext()); context = event.getServletContext(); if (webApplicationContext.containsBean("appScheduler")) { scheduler = (AppScheduler) webApplicationContext.getBean("appScheduler"); //scheduler = new AppScheduler(); scheduler.init();//w w w . j a v a 2 s . c o m } log.info("Context " + context.getServletContextName() + " initialized"); }
From source file:org.apereo.portal.utils.PortalApplicationContextLocator.java
@Override public void contextInitialized(ServletContextEvent sce) { servletContext = sce.getServletContext(); }
From source file:org.sindice.summary.rest.SummaryRestContextListener.java
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); logger.info("initializing SummaryRest context"); final ServletContext context = sce.getServletContext(); final XMLConfiguration config = (XMLConfiguration) context.getAttribute("config"); /*/*from w w w . j a va 2s .c o m*/ * TODO: Find a better way to get these backend configurations */ final String recommenderBackend = getParameterWithLogging(config, RECOMMENDER_BACKEND, BackendType.HTTP.toString()); final String[] recommenderBackendArgs = getParametersWithLogging(config, RECOMMENDER_BACKEND_ARGS, new String[] { "" }); final String proxyBackend = getParameterWithLogging(config, PROXY_BACKEND, BackendType.HTTP.toString()); final String[] proxyBackendArgs = getParametersWithLogging(config, PROXY_BACKEND_ARGS, new String[] { "" }); context.setAttribute(RECOMMENDER_BACKEND, recommenderBackend); context.setAttribute(RECOMMENDER_BACKEND_ARGS, recommenderBackendArgs); context.setAttribute(PROXY_BACKEND, proxyBackend); context.setAttribute(PROXY_BACKEND_ARGS, proxyBackendArgs); logger.info("{}={} {}={} {}={} {}={}", new Object[] { PROXY_BACKEND, proxyBackend, PROXY_BACKEND_ARGS, Arrays.toString(proxyBackendArgs), RECOMMENDER_BACKEND, recommenderBackend, RECOMMENDER_BACKEND_ARGS, Arrays.toString(recommenderBackendArgs) }); }
From source file:com.kesdip.license.web.listener.SchemaUpdateContextListener.java
/** * Access Spring context, get <code>schemaUpdater</code> and call it. * //from ww w . j a v a 2 s. co m * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent contextEvent) { logger.info("Getting Spring ApplicationContext"); ApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(contextEvent.getServletContext()); logger.info("Init SchemaUpdater"); SchemaUpdater schemaUpdater = new SchemaUpdater(SQL_PKG, getClass().getClassLoader(), VERSIONS); logger.info("Update schema"); schemaUpdater.updateSchema((HibernateTemplate) context.getBean("hibernateTemplate")); }
From source file:com.oneops.metrics.admin.MetricsContextListener.java
@Override public void contextInitialized(ServletContextEvent sce) { logger.info("Initializing the Metrics Servlet Context Listener."); final ServletContext context = sce.getServletContext(); // Autowire this context listener WebApplicationContextUtils.getWebApplicationContext(context).getAutowireCapableBeanFactory() .autowireBean(this); context.setAttribute(METRICS_REGISTRY, ooMetricsRegistry); context.setAttribute(FILTER_REGISTRY, ooMetricsRegistry); context.setAttribute(HEALTH_CHECK_REGISTRY, ooHealthRegistry); context.setAttribute(RATE_UNIT, getRateUnit()); context.setAttribute(DURATION_UNIT, getDurationUnit()); context.setAttribute(ALLOWED_ORIGIN, getAllowedOrigin()); context.setAttribute(HEALTH_CHECK_EXECUTOR, getExecutorService()); MetricsElasticsearchModule.context.put("appName", context.getServletContextName()); MetricsElasticsearchModule.context.put("oo.version", version.getGitVersion()); }
From source file:org.dms.sys.web.app.ContextListener.java
/** * Context initialized./* www . j a va 2 s.c o m*/ * * @param event the event * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent event) { // make sure that the spaces store in the repository exists this.servletContext = event.getServletContext(); WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext); // If no context has been initialised, exit silently so config changes can be made if (ctx == null) { return; } synchronized (this) { findEnterpriseListener(); if (enterpriseListener != null) { // Perform any extra context initialisation required for enterprise. enterpriseListener.contextInitialized(event); } } }