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
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
35 extends BaseServiceBroker
36 implements ServiceManager
37 {
38 /*** The single instance of this class. */
39 private static ServiceManager instance = new TurbineServices();
40
41 /***
42 * This constructor is protected to force clients to use
43 * getInstance() to access this class.
44 */
45 protected TurbineServices()
46 {
47 super();
48 }
49
50 /***
51 * The method through which this class is accessed as a broker.
52 *
53 * @return The single instance of this class.
54 */
55 public static ServiceManager getInstance()
56 {
57 return instance;
58 }
59
60 /***
61 * The method through which to change the default manager.
62 * Note that services of the previous manager will be shutdown.
63 * @param manager a new service manager.
64 */
65 public static synchronized void setManager(ServiceManager manager)
66 {
67 ServiceManager previous = instance;
68 instance = manager;
69 if (previous != null)
70 {
71 previous.shutdownServices();
72 }
73 }
74 }