FileDocCategorySizeDatePackage
ResourceManagerListener.javaAPI DocExample1778Tue Feb 28 11:34:06 GMT 2006com.ora.jsp.servlets

ResourceManagerListener

public class ResourceManagerListener extends Object implements ServletContextListener
This class manages the resources used by the Project Billboard application, creating them and making them available when the application starts and removing them when the application is shut down.
author
Hans Bergsten, Gefion software
version
1.0

Fields Summary
Constructors Summary
Methods Summary
public voidcontextDestroyed(javax.servlet.ServletContextEvent sce)

        ServletContext application  = sce.getServletContext();
        application.removeAttribute("empReg");
        application.removeAttribute("news");
    
public voidcontextInitialized(javax.servlet.ServletContextEvent sce)

        ServletContext application  = sce.getServletContext();

        /*
         * Get the JDBC driver class name and URL from web.xml
         * context init parameters
         */
        String driverClass = application.getInitParameter("driverClass");
        String jdbcURL = application.getInitParameter("jdbcURL");

        DataSourceWrapper ds = null;
        try {
            ds = new DataSourceWrapper();
            ds.setDriverClassName(driverClass);
            ds.setUrl(jdbcURL);
        }
        catch (Exception e) {
            application.log("Error creating connection pool: ", e);
        } 
        EmployeeRegistryBean empReg = new EmployeeRegistryBean();
        empReg.setDataSource(ds);
        application.setAttribute("empReg", empReg);

        NewsBean news = new NewsBean();
        application.setAttribute("news", news);