1 19 20 21 package org.netbeans.server.uihandler; 22 23 import java.io.InputStreamReader ; 24 import java.net.URL ; 25 import java.util.Enumeration ; 26 import java.util.logging.Level ; 27 import java.util.logging.Logger ; 28 import javax.naming.Binding ; 29 import javax.naming.Context ; 30 import javax.naming.InitialContext ; 31 import javax.naming.NameClassPair ; 32 import javax.naming.NamingEnumeration ; 33 import javax.naming.NamingException ; 34 import javax.servlet.ServletContextEvent ; 35 import javax.servlet.ServletContextListener ; 36 import org.netbeans.server.componentsmatch.Matcher; 37 38 42 public class OnDeploy implements ServletContextListener { 43 44 45 public OnDeploy() { 46 } 47 48 public void contextInitialized(ServletContextEvent ev) { 49 if (LogsManager.LOG.isLoggable(Level.INFO)) { 50 try { 51 LogsManager.LOG.warning("printing bindings"); Utils.printContext("", null); 53 } catch (Exception ex) { 54 LogsManager.LOG.log(Level.SEVERE, ex.getMessage(), ex); 55 } finally { 56 LogsManager.LOG.warning("end of bindings"); } 58 } 59 try { 60 Class.forName("com.mysql.jdbc.Driver").newInstance(); Utils.setConnection(); 62 Matcher.read(new InputStreamReader (Matcher.class.getResourceAsStream("componentmapping.txt"))); 63 } catch (Exception ex) { 64 LogsManager.LOG.log(Level.SEVERE, "Impossible to initialize database", ex); 65 } 66 67 try { 68 LogsManager.getDefault(); 69 } catch (Exception ex) { 70 LogsManager.LOG.log(Level.SEVERE, "Failure initializing data", ex); 71 } 72 } 73 74 public void contextDestroyed(ServletContextEvent ev) { 75 LogsManager.getDefault().close(); 76 Utils.closeConnection(); 77 } 78 79 } 80 | Popular Tags |