001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina;
018:
019: import org.apache.catalina.deploy.NamingResources;
020:
021: /**
022: * A <code>Server</code> element represents the entire Catalina
023: * servlet container. Its attributes represent the characteristics of
024: * the servlet container as a whole. A <code>Server</code> may contain
025: * one or more <code>Services</code>, and the top level set of naming
026: * resources.
027: * <p>
028: * Normally, an implementation of this interface will also implement
029: * <code>Lifecycle</code>, such that when the <code>start()</code> and
030: * <code>stop()</code> methods are called, all of the defined
031: * <code>Services</code> are also started or stopped.
032: * <p>
033: * In between, the implementation must open a server socket on the port number
034: * specified by the <code>port</code> property. When a connection is accepted,
035: * the first line is read and compared with the specified shutdown command.
036: * If the command matches, shutdown of the server is initiated.
037: * <p>
038: * <strong>NOTE</strong> - The concrete implementation of this class should
039: * register the (singleton) instance with the <code>ServerFactory</code>
040: * class in its constructor(s).
041: *
042: * @author Craig R. McClanahan
043: * @version $Revision: 1.3 $ $Date: 2004/05/26 15:28:34 $
044: */
045:
046: public interface Server {
047:
048: // ------------------------------------------------------------- Properties
049:
050: /**
051: * Return descriptive information about this Server implementation and
052: * the corresponding version number, in the format
053: * <code><description>/<version></code>.
054: */
055: public String getInfo();
056:
057: /**
058: * Return the global naming resources.
059: */
060: public NamingResources getGlobalNamingResources();
061:
062: /**
063: * Set the global naming resources.
064: *
065: * @param globalNamingResources The new global naming resources
066: */
067: public void setGlobalNamingResources(
068: NamingResources globalNamingResources);
069:
070: /**
071: * Return the port number we listen to for shutdown commands.
072: */
073: public int getPort();
074:
075: /**
076: * Set the port number we listen to for shutdown commands.
077: *
078: * @param port The new port number
079: */
080: public void setPort(int port);
081:
082: /**
083: * Return the shutdown command string we are waiting for.
084: */
085: public String getShutdown();
086:
087: /**
088: * Set the shutdown command we are waiting for.
089: *
090: * @param shutdown The new shutdown command
091: */
092: public void setShutdown(String shutdown);
093:
094: // --------------------------------------------------------- Public Methods
095:
096: /**
097: * Add a new Service to the set of defined Services.
098: *
099: * @param service The Service to be added
100: */
101: public void addService(Service service);
102:
103: /**
104: * Wait until a proper shutdown command is received, then return.
105: */
106: public void await();
107:
108: /**
109: * Return the specified Service (if it exists); otherwise return
110: * <code>null</code>.
111: *
112: * @param name Name of the Service to be returned
113: */
114: public Service findService(String name);
115:
116: /**
117: * Return the set of Services defined within this Server.
118: */
119: public Service[] findServices();
120:
121: /**
122: * Remove the specified Service from the set associated from this
123: * Server.
124: *
125: * @param service The Service to be removed
126: */
127: public void removeService(Service service);
128:
129: /**
130: * Invoke a pre-startup initialization. This is used to allow connectors
131: * to bind to restricted ports under Unix operating environments.
132: *
133: * @exception LifecycleException If this server was already initialized.
134: */
135: public void initialize() throws LifecycleException;
136: }
|