KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > server > uihandler > OnDeploy


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.server.uihandler;
22
23 import java.io.InputStreamReader JavaDoc;
24 import java.net.URL JavaDoc;
25 import java.util.Enumeration JavaDoc;
26 import java.util.logging.Level JavaDoc;
27 import java.util.logging.Logger JavaDoc;
28 import javax.naming.Binding JavaDoc;
29 import javax.naming.Context JavaDoc;
30 import javax.naming.InitialContext JavaDoc;
31 import javax.naming.NameClassPair JavaDoc;
32 import javax.naming.NamingEnumeration JavaDoc;
33 import javax.naming.NamingException JavaDoc;
34 import javax.servlet.ServletContextEvent JavaDoc;
35 import javax.servlet.ServletContextListener JavaDoc;
36 import org.netbeans.server.componentsmatch.Matcher;
37
38 /**
39  *
40  * @author jindra
41  */

42 public class OnDeploy implements ServletContextListener JavaDoc{
43     
44     /** Creates a new instance of OnDeploy */
45     public OnDeploy() {
46     }
47
48     public void contextInitialized(ServletContextEvent JavaDoc ev) {
49         if (LogsManager.LOG.isLoggable(Level.INFO)) {
50             try {
51                 LogsManager.LOG.warning("printing bindings"); // NOI18N
52
Utils.printContext("", null);
53             } catch (Exception JavaDoc ex) {
54                 LogsManager.LOG.log(Level.SEVERE, ex.getMessage(), ex);
55             } finally {
56                 LogsManager.LOG.warning("end of bindings"); // NOI18N
57
}
58         }
59         try {
60             Class.forName("com.mysql.jdbc.Driver").newInstance(); // NOI18N
61
Utils.setConnection();
62             Matcher.read(new InputStreamReader JavaDoc(Matcher.class.getResourceAsStream("componentmapping.txt")));
63         } catch (Exception JavaDoc ex) {
64             LogsManager.LOG.log(Level.SEVERE, "Impossible to initialize database", ex);
65         }
66
67         try {
68             LogsManager.getDefault();
69         } catch (Exception JavaDoc ex) {
70             LogsManager.LOG.log(Level.SEVERE, "Failure initializing data", ex);
71         }
72     }
73     
74     public void contextDestroyed(ServletContextEvent JavaDoc ev) {
75         LogsManager.getDefault().close();
76         Utils.closeConnection();
77     }
78     
79 }
80
Popular Tags