KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tester > ContextListener02


1 /*
2  * Copyright 1999, 2000, 2001 ,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.tester;
18
19
20 import java.beans.PropertyEditorManager JavaDoc;
21 import java.sql.Date JavaDoc;
22 import javax.servlet.ServletContext JavaDoc;
23 import javax.servlet.ServletContextEvent JavaDoc;
24 import javax.servlet.ServletContextListener JavaDoc;
25
26
27 /**
28  * Application event listener for context events. Ensures that the property
29  * editor classes for this web application are appropriately registered.
30  *
31  * @author Craig R. McClanahan
32  * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:56 $
33  */

34
35 public class ContextListener02
36     implements ServletContextListener JavaDoc {
37
38
39     private ServletContext JavaDoc context = null;
40
41
42     public void contextDestroyed(ServletContextEvent JavaDoc event) {
43         context.log("ContextListener02: contextDestroyed()");
44         context = null;
45     }
46
47     public void contextInitialized(ServletContextEvent JavaDoc event) {
48         context = (ServletContext JavaDoc) event.getSource();
49         context.log("ContextListener02: contextInitialized()");
50         PropertyEditorManager.registerEditor(Date JavaDoc.class,
51                                              DatePropertyEditor.class);
52         context.log("ContextListener02: getEditorSearchPath() -->");
53         String JavaDoc search[] = PropertyEditorManager.getEditorSearchPath();
54         if (search == null)
55             search = new String JavaDoc[0];
56         for (int i = 0; i < search.length; i++)
57             context.log("ContextListener02: " + search[i]);
58         context.log("ContextListener02: findEditor() --> " +
59                     PropertyEditorManager.findEditor(Date JavaDoc.class));
60                
61     }
62
63
64 }
65
Popular Tags