⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 startuplistener.java

📁 自己写的一个struts+spring+hibernate测试程序
💻 JAVA
字号:
/*
 * Created on 2006-2-16
 */
package com.common.listener;
import java.io.File;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.sql.DataSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.common.Constants;
import com.common.db.DBUtils;



/**
 * 
 * <p>Title:struts 启动Listener类 </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: </p>
 * @author czl
 * @version 1.0
 */
public class StartupListener extends ContextLoaderListener implements
		ServletContextListener {

	private static final Log log = LogFactory.getLog(StartupListener.class);

	public void contextInitialized(ServletContextEvent event) {
		if (log.isDebugEnabled()) {
			log.debug("initializing context...");
		}

		// call Spring's context ContextLoaderListener to initialize
		// all the context files specified in web.xml
		super.contextInitialized(event);

		ServletContext context = event.getServletContext();
		
		//added by tommy 2006-06-09 to set application's real path
		
		// Orion starts Servlets before Listeners, so check if the config
        Constants.BASEPATH=context.getRealPath(File.separator);
		ApplicationContext ctx = WebApplicationContextUtils
				.getRequiredWebApplicationContext(context);

		if (log.isDebugEnabled()) {
			log.debug("initializing DB utils...");
		}
		DBUtils.getInstance().setDataSource((DataSource) ctx.getBean("dataSource"));


		setupContext(context);
	}

	public static void setupContext(ServletContext context) {

	}

	
	public void contextDestroyed(ServletContextEvent arg0) {
		super.contextDestroyed(arg0);
		if (log.isDebugEnabled()) {
			log.debug("destroying context...");
		}
		if(log.isInfoEnabled()){
			log.info("stop the flow scheduling daemon...");
		}
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -