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