01: /*
02: * Copyright 1999,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.catalina;
18:
19: import org.apache.catalina.core.StandardServer;
20:
21: /**
22: * <p><strong>ServerFactory</strong> allows the registration of the
23: * (singleton) <code>Server</code> instance for this JVM, so that it
24: * can be accessed independently of any existing reference to the
25: * component hierarchy. This is important for administration tools
26: * that are built around the internal component implementation classes.
27: *
28: * @author Craig R. McClanahan
29: * @version $Revision: 1.3 $ $Date: 2004/02/27 14:58:39 $
30: */
31:
32: public class ServerFactory {
33:
34: // ------------------------------------------------------- Static Variables
35:
36: /**
37: * The singleton <code>Server</code> instance for this JVM.
38: */
39: private static Server server = null;
40:
41: // --------------------------------------------------------- Public Methods
42:
43: /**
44: * Return the singleton <code>Server</code> instance for this JVM.
45: */
46: public static Server getServer() {
47: if (server == null)
48: server = new StandardServer();
49: return (server);
50:
51: }
52:
53: /**
54: * Set the singleton <code>Server</code> instance for this JVM. This
55: * method must <strong>only</strong> be called from a constructor of
56: * the (singleton) <code>Server</code> instance that is created for
57: * this execution of Catalina.
58: *
59: * @param theServer The new singleton instance
60: */
61: public static void setServer(Server theServer) {
62:
63: if (server == null)
64: server = theServer;
65:
66: }
67:
68: }
|