001: package org.apache.turbine.services;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.apache.commons.configuration.Configuration;
023:
024: /**
025: * Classes that implement this interface can act as a broker for
026: * <code>Service</code> classes.
027: *
028: * Functionality that <code>ServiceBroker</code> provides in addition
029: * to <code>InitableBroker</code> functionality includes:
030: *
031: * <ul>
032: *
033: * <li>Maintaining service name to class name mapping, allowing
034: * plugable service implementations.</li>
035: *
036: * <li>Providing <code>Services</code> with <code>Properties</code>
037: * based on a system wide configuration mechanism.</li>
038: *
039: * </ul>
040: *
041: * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
042: * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
043: * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
044: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
045: * @version $Id: ServiceBroker.java 534527 2007-05-02 16:10:59Z tv $
046: */
047: public interface ServiceBroker {
048: /**
049: * Determines whether a service is registered in the configured
050: * <code>TurbineResources.properties</code>.
051: *
052: * @param serviceName The name of the service whose existance to check.
053: * @return Registration predicate for the desired services.
054: */
055: boolean isRegistered(String serviceName);
056:
057: /**
058: * Performs early initialization of the specified service.
059: *
060: * @param name The name of the service.
061: * @exception InitializationException if the service is unknown
062: * or can't be initialized.
063: */
064: void initService(String name) throws InitializationException;
065:
066: /**
067: * Shutdowns a Service.
068: *
069: * This method is used to release resources allocated by a
070: * Service, and return it to initial (uninitailized) state.
071: *
072: * @param name The name of the Service to be uninitialized.
073: */
074: void shutdownService(String name);
075:
076: /**
077: * Shutdowns all Services.
078: *
079: * This method is used to release resources allocated by
080: * Services, and return them to initial (uninitialized) state.
081: */
082: void shutdownServices();
083:
084: /**
085: * Returns an instance of requested Service.
086: *
087: * @param name The name of the Service requested.
088: * @return An instance of requested Service.
089: * @exception InstantiationException if the service is unknown or
090: * can't be initialized.
091: */
092: Service getService(String name) throws InstantiationException;
093:
094: /**
095: * Returns the configuration of a specific service. Services
096: * use this method to retrieve their configuration.
097: *
098: * @param name The name of the service.
099: * @return Configuration of the requested service.
100: */
101: Configuration getConfiguration(String name);
102: }
|