javax.servlet.ServletContextEvent#getServletContext ( )源码实例Demo

下面列出了javax.servlet.ServletContextEvent#getServletContext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hmdm-server   文件: Initializer.java
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();
}
 
源代码2 项目: myspring   文件: ContextLoaderListener.java
/**
     * 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);
    }
 
源代码3 项目: Tomcat8-Source-Read   文件: TesterTldListener.java
@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");
    }
}
 
@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();
}
 
源代码5 项目: openemm   文件: ExecutorShutdownListener.java
@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);
	}
}
 
@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);
	}
}
 
源代码7 项目: MeetingFilm   文件: ConfigListener.java
@Override
public void contextInitialized(ServletContextEvent evt) {
    ServletContext sc = evt.getServletContext();

    //项目发布,当前运行环境的绝对路径
    conf.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));

    //servletContextPath,默认""
    conf.put("contextPath", sc.getContextPath());
}
 
源代码8 项目: Tomcat8-Source-Read   文件: WsContextListener.java
@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);
    }
}
 
源代码9 项目: web-flash   文件: ConfigListener.java
@Override
public void contextInitialized(ServletContextEvent evt) {
    ServletContext sc = evt.getServletContext();
    // 项目路径
    conf.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));
    conf.put("contextPath", sc.getContextPath());
}
 
源代码10 项目: WebStack-Guns   文件: ConfigListener.java
@Override
public void contextInitialized(ServletContextEvent evt) {
    ServletContext sc = evt.getServletContext();

    //项目发布,当前运行环境的绝对路径
    conf.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));

    //servletContextPath,默认""
    conf.put("contextPath", sc.getContextPath());
}
 
源代码11 项目: Tomcat8-Source-Read   文件: TesterTldListener.java
@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");
    }
}
 
源代码12 项目: HotelSystem   文件: MyServletContextListener.java
@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);
}
 
@Override
public final void contextInitialized(final ServletContextEvent servletContextEvent) {
	final ServletContext servletContext = servletContextEvent.getServletContext();
	webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);

	updateMarkedCompanies();
}
 
@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");
	}
}
 
@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);
	}
}
 
@Override
public void contextInitialized(ServletContextEvent sce) {
    Stockticker stockticker = new Stockticker();
    ServletContext sc = sce.getServletContext();
    sc.setAttribute(STOCK_TICKER_KEY, stockticker);
}
 
@Override
public void contextDestroyed(ServletContextEvent sce) {
    ServletContext sc = sce.getServletContext();
    Stockticker stockticker = (Stockticker) sc.getAttribute(STOCK_TICKER_KEY);
    stockticker.shutdown();
}
 
@Override
public void contextInitialized(ServletContextEvent sce) {
    Stockticker stockticker = new Stockticker();
    ServletContext sc = sce.getServletContext();
    sc.setAttribute(STOCK_TICKER_KEY, stockticker);
}
 
源代码19 项目: code   文件: UserListener.java
@Override
public void contextInitialized(ServletContextEvent arg0) {
    // TODO Auto-generated method stub
    ServletContext servletContext = arg0.getServletContext();
    System.out.println("UserListener...contextInitialized...");
}
 
源代码20 项目: Tomcat8-Source-Read   文件: TestListener.java
@Override
public void contextInitialized(ServletContextEvent sce) {
    ServletContext sc = sce.getServletContext();
    sc.addListener(SCL3.class.getName());
}
 
 同类方法