01: package org.apache.turbine.services;
02:
03: /*
04: * Copyright 2001-2005 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License")
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * This is a singleton utility class that acts as a Services broker.
21: *
22: * @author <a href="mailto:greg@shwoop.com">Greg Ritter</a>
23: * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
24: * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
25: * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
26: * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
27: * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
28: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
29: * @version $Id: TurbineServices.java 264148 2005-08-29 14:21:04Z henning $
30: */
31: public class TurbineServices extends BaseServiceBroker implements
32: ServiceManager {
33: /** The single instance of this class. */
34: private static ServiceManager instance = new TurbineServices();
35:
36: /**
37: * This constructor is protected to force clients to use
38: * getInstance() to access this class.
39: */
40: protected TurbineServices() {
41: super ();
42: }
43:
44: /**
45: * The method through which this class is accessed as a broker.
46: *
47: * @return The single instance of this class.
48: */
49: public static ServiceManager getInstance() {
50: return instance;
51: }
52:
53: /**
54: * The method through which to change the default manager.
55: * Note that services of the previous manager will be shutdown.
56: * @param manager a new service manager.
57: */
58: public static synchronized void setManager(ServiceManager manager) {
59: ServiceManager previous = instance;
60: instance = manager;
61: if (previous != null) {
62: previous.shutdownServices();
63: }
64: }
65: }
|