1 package org.apache.turbine.services;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
32 extends BaseServiceBroker
33 implements ServiceManager
34 {
35 /*** The single instance of this class. */
36 private static ServiceManager instance = new TurbineServices();
37
38 /***
39 * This constructor is protected to force clients to use
40 * getInstance() to access this class.
41 */
42 protected TurbineServices()
43 {
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 {
54 return instance;
55 }
56
57 /***
58 * The method through which to change the default manager.
59 * Note that services of the previous manager will be shutdown.
60 * @param manager a new service manager.
61 */
62 public static synchronized void setManager(ServiceManager manager)
63 {
64 ServiceManager previous = instance;
65 instance = manager;
66 if (previous != null)
67 {
68 previous.shutdownServices();
69 }
70 }
71 }