KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > container > startup > ServletContainerListener


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

15
16 package com.jdon.container.startup;
17
18 import java.io.Serializable JavaDoc;
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22 import javax.servlet.ServletContext JavaDoc;
23 import javax.servlet.ServletContextEvent JavaDoc;
24 import javax.servlet.ServletContextListener JavaDoc;
25 import javax.servlet.http.HttpSessionEvent JavaDoc;
26
27 import com.jdon.container.config.app.AppConfigureCollection;
28 import com.jdon.util.Debug;
29 import com.jdon.util.StringUtil;
30
31 /**
32  * Bootstrap listener to start up Jdon Framework
33  * it delegates to ContainerSetupScript
34  *
35  * setup web.xml
36  * <listener>
37         <listener-class>com.jdon.container.startup.ServletContainerListener</listener-class>
38     </listener>
39
40  * @author banq
41  */

42 public class ServletContainerListener implements ServletContextListener JavaDoc, Serializable JavaDoc {
43
44   public final static String JavaDoc module = ServletContainerListener.class.getName();
45
46   private ContainerSetupScript css = new ContainerSetupScript();
47
48   public void contextInitialized(ServletContextEvent JavaDoc event) {
49     ServletContext JavaDoc context = event.getServletContext();
50     css.initialized(context);
51     Debug.logVerbose("[JdonFramework]contextInitialized", module);
52     
53     String JavaDoc app_configFile = context.getInitParameter(AppConfigureCollection.CONFIG_NAME);
54     String JavaDoc[] configs = StringUtil.split(app_configFile, ",");
55     for(int i = 0 ; i < configs.length; i ++){
56       Debug.logVerbose("[JdonFramework] locate a configuration in web.xml :" + configs[i], module);
57       css.prepare(configs[i], context);
58     }
59     Debug.logVerbose("[JdonFramework]ServletContainerListener is preparing...", module);
60   
61   }
62
63   public void contextDestroyed(ServletContextEvent JavaDoc event) {
64     ServletContext JavaDoc context = event.getServletContext();
65     css.destroyed(context);
66
67   }
68
69   public void sessionCreated(HttpSessionEvent JavaDoc event) {
70
71   }
72
73   public void sessionDestroyed(HttpSessionEvent JavaDoc event) {
74   }
75
76 }
77
Popular Tags