📄 factoryloaderlistener.java
字号:
package org.yeeku.web;
import javax.servlet.*;
import org.yeeku.factory.*;
import org.hibernate.SessionFactory;
/**
* @author yeeku.H.lee kongyeeku@163.com
* @version 1.0
* <br>Copyright (C), 2005-2008, yeeku.H.Lee
* <br>This program is protected by copyright laws.
* <br>Program Name:
* <br>Date:
*/
public class FactoryLoaderListener implements ServletContextListener
{
DaoFactory df = null;
SessionFactory sf = null;
public void contextInitialized(ServletContextEvent sce)
{
try
{
sf = SessionFactoryBuilder.instance().getSessionFactory();
System.out.println("Hibernate的SessionFactory已经被初始化... " + sf);
}
catch (Exception e)
{
System.out.println("初始化SessionFactory工厂时出现异常" + e);
}
try
{
String path = sce.getServletContext().getRealPath("/WEB-INF/");
df = DaoFactory.instance(path);
System.out.println("DAO工厂已经被初始化... " + df);
}
catch (Exception e)
{
System.out.println("初始化DAO工厂时出现异常" + e);
}
}
public void contextDestroyed(ServletContextEvent sce)
{
sf = null;
df = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -