KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > Server


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

17
18
19 package org.apache.catalina;
20
21 import org.apache.catalina.deploy.NamingResources;
22
23 /**
24  * A <code>Server</code> element represents the entire Catalina
25  * servlet container. Its attributes represent the characteristics of
26  * the servlet container as a whole. A <code>Server</code> may contain
27  * one or more <code>Services</code>, and the top level set of naming
28  * resources.
29  * <p>
30  * Normally, an implementation of this interface will also implement
31  * <code>Lifecycle</code>, such that when the <code>start()</code> and
32  * <code>stop()</code> methods are called, all of the defined
33  * <code>Services</code> are also started or stopped.
34  * <p>
35  * In between, the implementation must open a server socket on the port number
36  * specified by the <code>port</code> property. When a connection is accepted,
37  * the first line is read and compared with the specified shutdown command.
38  * If the command matches, shutdown of the server is initiated.
39  * <p>
40  * <strong>NOTE</strong> - The concrete implementation of this class should
41  * register the (singleton) instance with the <code>ServerFactory</code>
42  * class in its constructor(s).
43  *
44  * @author Craig R. McClanahan
45  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
46  */

47
48 public interface Server {
49
50
51     // ------------------------------------------------------------- Properties
52

53
54     /**
55      * Return descriptive information about this Server implementation and
56      * the corresponding version number, in the format
57      * <code>&lt;description&gt;/&lt;version&gt;</code>.
58      */

59     public String JavaDoc getInfo();
60
61
62     /**
63      * Return the global naming resources.
64      */

65     public NamingResources getGlobalNamingResources();
66
67
68     /**
69      * Set the global naming resources.
70      *
71      * @param globalNamingResources The new global naming resources
72      */

73     public void setGlobalNamingResources
74         (NamingResources globalNamingResources);
75
76
77     /**
78      * Return the port number we listen to for shutdown commands.
79      */

80     public int getPort();
81
82
83     /**
84      * Set the port number we listen to for shutdown commands.
85      *
86      * @param port The new port number
87      */

88     public void setPort(int port);
89
90
91     /**
92      * Return the shutdown command string we are waiting for.
93      */

94     public String JavaDoc getShutdown();
95
96
97     /**
98      * Set the shutdown command we are waiting for.
99      *
100      * @param shutdown The new shutdown command
101      */

102     public void setShutdown(String JavaDoc shutdown);
103
104
105     // --------------------------------------------------------- Public Methods
106

107
108     /**
109      * Add a new Service to the set of defined Services.
110      *
111      * @param service The Service to be added
112      */

113     public void addService(Service service);
114
115
116     /**
117      * Wait until a proper shutdown command is received, then return.
118      */

119     public void await();
120
121
122     /**
123      * Return the specified Service (if it exists); otherwise return
124      * <code>null</code>.
125      *
126      * @param name Name of the Service to be returned
127      */

128     public Service findService(String JavaDoc name);
129
130
131     /**
132      * Return the set of Services defined within this Server.
133      */

134     public Service[] findServices();
135
136
137     /**
138      * Remove the specified Service from the set associated from this
139      * Server.
140      *
141      * @param service The Service to be removed
142      */

143     public void removeService(Service service);
144
145     /**
146      * Invoke a pre-startup initialization. This is used to allow connectors
147      * to bind to restricted ports under Unix operating environments.
148      *
149      * @exception LifecycleException If this server was already initialized.
150      */

151     public void initialize()
152     throws LifecycleException;
153 }
154
Popular Tags