KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > PwcWebContainer


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.web;
25
26 import org.apache.catalina.startup.Embedded;
27 import org.apache.catalina.Logger;
28 import org.apache.catalina.Engine;
29 import org.apache.catalina.Lifecycle;
30 import org.apache.catalina.Container;
31
32 /*
33  * Represents the production web container
34  */

35 public class PwcWebContainer implements PwcWebContainerLifecycle {
36
37     /**
38      * The parent/top-level container in <code>_embedded</code> for virtual
39      * servers.
40      */

41     private Engine _engine = null;
42
43    /**
44      * The embedded Catalina object.
45      */

46     private Embedded _embedded = null;
47
48
49     /**
50      * Has this component been started yet?
51      */

52     private boolean _started = false;
53
54     public void onInitialization(String JavaDoc rootDir, String JavaDoc instanceName,
55                                  boolean useNaming, Logger logger,
56                                  String JavaDoc embeddedClassName)
57         throws Exception JavaDoc {
58         Class JavaDoc c = Class.forName(embeddedClassName);
59         _embedded = (Embedded) c.newInstance();
60         _embedded.setUseNaming(useNaming);
61         _embedded.setLogger(logger);
62         _engine = _embedded.createEngine();
63         _embedded.addEngine(_engine);
64     }
65
66     public void onStartup()
67         throws Exception JavaDoc {
68         _started = true;
69
70         _embedded.start();
71
72     }
73
74     public void onReady()
75         throws Exception JavaDoc {
76     }
77
78  
79     public void onShutdown()
80         throws Exception JavaDoc {
81     }
82
83
84     public void onTermination()
85         throws Exception JavaDoc {
86         _started = false;
87         _embedded.stop();
88     }
89
90     public Engine getEngine() {
91         return _engine;
92     }
93
94     public Embedded getEmbedded() {
95         return _embedded;
96     }
97
98 }
99
Popular Tags