View Javadoc

1   package org.apache.turbine.services;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "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
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  }