001package org.apache.turbine.services;
002
003
004/*
005 * Licensed to the Apache Software Foundation (ASF) under one
006 * or more contributor license agreements.  See the NOTICE file
007 * distributed with this work for additional information
008 * regarding copyright ownership.  The ASF licenses this file
009 * to you under the Apache License, Version 2.0 (the
010 * "License"); you may not use this file except in compliance
011 * with the License.  You may obtain a copy of the License at
012 *
013 *   http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing,
016 * software distributed under the License is distributed on an
017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018 * KIND, either express or implied.  See the License for the
019 * specific language governing permissions and limitations
020 * under the License.
021 */
022
023
024import java.util.Properties;
025
026import org.apache.commons.configuration2.Configuration;
027
028/**
029 * <code>Services</code> are <code>Initables</code> that have a name,
030 * and a set of properties.
031 *
032 * @author <a href="mailto:greg@shwoop.com">Greg Ritter</a>
033 * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
034 * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
035 * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
036 * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
037 * @version $Id$
038 */
039public interface Service
040        extends Initable
041{
042    /** The name of this service. */
043    String SERVICE_NAME = "Service";
044
045    /**
046     * Provides a Service with a reference to the ServiceBroker that
047     * instantiated this object, so that it can ask for its properties
048     * and access other Services.
049     *
050     * @param broker The ServiceBroker that instantiated this object.
051     */
052    void setServiceBroker(ServiceBroker broker);
053
054    /**
055     * ServiceBroker uses this method to pass a Service its name.
056     * Service uses its name to ask the broker for an apropriate set
057     * of Properties.
058     *
059     * @param name The name of this Service.
060     */
061    void setName(String name);
062
063    /**
064     * Returns the name of this Service.
065     *
066     * @return The name of this Service.
067     */
068    String getName();
069
070    /**
071     * Returns the Properties of this Service.  Every Service has at
072     * least one property, which is "classname", containing the name
073     * of the class implementing this service.  Note that the service
074     * may chose to alter its properties, therefore they may be
075     * different from those returned by ServiceBroker.
076     *
077     * @return The properties of this Service.
078     */
079    Properties getProperties();
080
081    /**
082     * Returns the Configuration of this Service.  Every Service has at
083     * least one property, which is "classname", containing the name
084     * of the class implementing this service.  Note that the service
085     * may chose to alter its configuration, therefore they may be
086     * different from those returned by ServiceBroker.
087     *
088     * @return The Configuration of this Service.
089     */
090    Configuration getConfiguration();
091}