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