Java Code Examples for javax.servlet.ServletContextEvent#getServletContext()
The following examples show how to use
javax.servlet.ServletContextEvent#getServletContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Initializer.java From hmdm-server with Apache License 2.0 | 6 votes |
public void contextInitialized(ServletContextEvent servletContextEvent) { this.context = servletContextEvent.getServletContext(); String log4jConfig = context.getInitParameter("log4j.config"); if (log4jConfig != null && !log4jConfig.isEmpty()) { System.out.println("[HMDM-LOGGING] : Using log4j configuration from: " + log4jConfig); System.setProperty("log4j.configuration", log4jConfig); System.setProperty("log4j.ignoreTCL", "true"); } else { System.out.println("[HMDM-LOGGING] Using log4j configuration from build"); } super.contextInitialized(servletContextEvent); initTasks(); }
Example 2
Source File: BirtMessagesPropertiesContextListener.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
@Override public void contextInitialized(ServletContextEvent event) { try { // Birt must generate messages in here, because it has no struts like EMM // Messages are then available via I18nString DBMessagesResource dbMessagesResource = new DBMessagesResource(); dbMessagesResource.init(); ServletContext servletContext = event.getServletContext(); if (ConfigService.getInstance().getBooleanValue(ConfigValue.IsLiveInstance)) { createMessagesPropertiesFiles(servletContext); } } catch (Exception e) { logger.error("MessagesPropertiesGeneratorContextListener init: " + e.getMessage(), e); } }
Example 3
Source File: ExecutorShutdownListener.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
@Override public void contextDestroyed(ServletContextEvent servletContextEvent) { try { ServletContext servletContext = servletContextEvent.getServletContext(); WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); ExecutorService workerExecutorService = (ExecutorService) webApplicationContext.getBean("WorkerExecutorService"); Thread.sleep(1000); logger.info("Shutting down WorkerExecutorService"); int retryCount = 0; while (!workerExecutorService.isTerminated() && retryCount < 10) { if (retryCount > 0) { logger.error("WorkerExecutorService shutdown retryCount: " + retryCount); Thread.sleep(1000); } workerExecutorService.shutdownNow(); retryCount++; } } catch (Exception e) { logger.error("Cannot shutdown WorkerExecutorService: " + e.getMessage(), e); } }
Example 4
Source File: PluginInstallationServletContextListener.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
@Override public void contextInitialized( ServletContextEvent event) { ServletContext servletContext = event.getServletContext(); String reportDesignPath = servletContext.getRealPath( ComExtensionConstants.PLUGIN_BIRT_RPTDESIGN_BASE); String scriptlibPath = servletContext.getRealPath(ComExtensionConstants.PLUGIN_BIRT_SCRIPTLIB_BASE); String pluginsPath; try { pluginsPath = ConfigService.getInstance().getValue(ConfigValue.EmmPluginsHome); } catch (Exception e) { logger.error("Cannot read EmmPluginsHome: " + e.getMessage(), e); throw new RuntimeException("Cannot read EmmPluginsHome: " + e.getMessage(), e); } if( logger.isDebugEnabled()) { logger.debug( "Path for report designs: " + reportDesignPath); logger.debug( "Path for script libs: " + scriptlibPath); logger.debug( "Path for plugin ZIPs: " + pluginsPath); } BirtPluginInstaller installer = new BirtPluginInstaller( pluginsPath, reportDesignPath, scriptlibPath); installer.installPlugins(); }
Example 5
Source File: TesterTldListener.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); servletContext = sc; // Try and use one of the Servlet 3.0 methods that should be blocked try { sc.getEffectiveMajorVersion(); log.append("FAIL-01"); } catch (UnsupportedOperationException uoe) { log.append("PASS-01"); } catch (Exception e) { log.append("FAIL-02"); } }
Example 6
Source File: ContextLoaderListener.java From myspring with MIT License | 6 votes |
/** * context初始化. */ @Override public void contextInitialized(ServletContextEvent event) { System.out.println("contextInitialized"); ServletContext servletContext = event.getServletContext(); if (null == this.context) { //配置的application文件路径 String cfgFile = servletContext.getInitParameter("contextConfigLocation"); this.context = new WebApplicationContext(cfgFile); //存入上下文,后面servlet会取用 servletContext.setAttribute(ROOT_CXT_ATTR, this.context); } //源码中是在这里初始化context,调用refresh方法的,我们在上面new的时候先做了 // initWebApplicationContext(this.context); }
Example 7
Source File: ConfigListener.java From web-flash with MIT License | 5 votes |
@Override public void contextInitialized(ServletContextEvent evt) { ServletContext sc = evt.getServletContext(); // 项目路径 conf.put("realPath", sc.getRealPath("/").replaceFirst("/", "")); conf.put("contextPath", sc.getContextPath()); }
Example 8
Source File: ConfigListener.java From WebStack-Guns with MIT License | 5 votes |
@Override public void contextInitialized(ServletContextEvent evt) { ServletContext sc = evt.getServletContext(); //项目发布,当前运行环境的绝对路径 conf.put("realPath", sc.getRealPath("/").replaceFirst("/", "")); //servletContextPath,默认"" conf.put("contextPath", sc.getContextPath()); }
Example 9
Source File: WsContextListener.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); // Don't trigger WebSocket initialization if a WebSocket Server // Container is already present if (sc.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE) == null) { WsSci.init(sce.getServletContext(), false); } }
Example 10
Source File: TesterTldListener.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void contextDestroyed(ServletContextEvent sce) { // Bug 57446. Same ServletContext should be presented as at init if (servletContext == sce.getServletContext()) { log.append("PASS-02"); } else { //log.append("FAIL-03"); } }
Example 11
Source File: MyServletContextListener.java From HotelSystem with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { /** * 注册服务单例 */ ServletContext sc = sce.getServletContext(); UserService userService = (UserService) BeanFactory.getBean(BeanFactory.ServiceType.UserService); sc.setAttribute("userService",userService); RoomService roomService = (RoomService) BeanFactory.getBean(BeanFactory.ServiceType.RoomService); sc.setAttribute("roomService",roomService); OrderRoomService orderRoomService = (OrderRoomService)BeanFactory.getBean(BeanFactory.ServiceType.OrderRoomService); sc.setAttribute("orderRoomService",orderRoomService); RemarkService remarkService = (RemarkService) BeanFactory.getBean((BeanFactory.ServiceType.RemarkService)); sc.setAttribute("remarkService",remarkService); }
Example 12
Source File: RebuildBindingHistoryTriggersOnStartupListener.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public final void contextInitialized(final ServletContextEvent servletContextEvent) { final ServletContext servletContext = servletContextEvent.getServletContext(); webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); updateMarkedCompanies(); }
Example 13
Source File: ExtensionSystemInitializationContextListener.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public void contextDestroyed(ServletContextEvent event) { ServletContext servletContext = event.getServletContext(); ExtensionSystemImpl extensionSystem = (ExtensionSystemImpl) servletContext.getAttribute(ExtensionConstants.EXTENSION_SYSTEM_APPLICATION_SCOPE_ATTRIBUTE); if (extensionSystem != null) { logger.info( "Shutting down ExtensionSystem"); extensionSystem.shutdown(); logger.info( "ExtensionSystem is shut down"); } }
Example 14
Source File: BackendDatasourceInitializationContextListener.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent event) { try { ServletContext servletContext = event.getServletContext(); ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); DBase.DATASOURCE = (DataSource) applicationContext.getBean("dataSource"); if (DBase.DATASOURCE == null) { logger.error("Datasource in DBase for Backend was empty. Backend will try to create its own datasource from emm.properties data"); } } catch (Exception e) { logger.error("Cannot set Datasource in DBase for Backend. Backend will try to create its own datasource from emm.properties data", e); } }
Example 15
Source File: ConfigListener.java From MeetingFilm with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent evt) { ServletContext sc = evt.getServletContext(); //项目发布,当前运行环境的绝对路径 conf.put("realPath", sc.getRealPath("/").replaceFirst("/", "")); //servletContextPath,默认"" conf.put("contextPath", sc.getContextPath()); }
Example 16
Source File: AsyncStockContextListener.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void contextInitialized(ServletContextEvent sce) { Stockticker stockticker = new Stockticker(); ServletContext sc = sce.getServletContext(); sc.setAttribute(STOCK_TICKER_KEY, stockticker); }
Example 17
Source File: UserListener.java From code with Apache License 2.0 | 4 votes |
@Override public void contextInitialized(ServletContextEvent arg0) { // TODO Auto-generated method stub ServletContext servletContext = arg0.getServletContext(); System.out.println("UserListener...contextInitialized..."); }
Example 18
Source File: TestListener.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void contextInitialized(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); sc.addListener(SCL3.class.getName()); }
Example 19
Source File: AsyncStockContextListener.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void contextDestroyed(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); Stockticker stockticker = (Stockticker) sc.getAttribute(STOCK_TICKER_KEY); stockticker.shutdown(); }
Example 20
Source File: AsyncStockContextListener.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void contextInitialized(ServletContextEvent sce) { Stockticker stockticker = new Stockticker(); ServletContext sc = sce.getServletContext(); sc.setAttribute(STOCK_TICKER_KEY, stockticker); }