View Javadoc

1   package org.apache.turbine.services;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.apache.commons.configuration.Configuration;
20  
21  /***
22   * Classes that implement this interface can act as a broker for
23   * <code>Service</code> classes.
24   *
25   * Functionality that <code>ServiceBroker</code> provides in addition
26   * to <code>InitableBroker</code> functionality includes:
27   *
28   * <ul>
29   *
30   * <li>Maintaining service name to class name mapping, allowing
31   * plugable service implementations.</li>
32   *
33   * <li>Providing <code>Services</code> with <code>Properties</code>
34   * based on a system wide configuration mechanism.</li>
35   *
36   * </ul>
37   *
38   * @author <a href="mailto:burton@apache.org">Kevin Burton</a>
39   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
40   * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
41   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
42   * @version $Id: ServiceBroker.java 264148 2005-08-29 14:21:04Z henning $
43   */
44  public interface ServiceBroker
45  {
46      /***
47       * Determines whether a service is registered in the configured
48       * <code>TurbineResources.properties</code>.
49       *
50       * @param serviceName The name of the service whose existance to check.
51       * @return Registration predicate for the desired services.
52       */
53      boolean isRegistered(String serviceName);
54  
55      /***
56       * Performs early initialization of the specified service.
57       *
58       * @param name The name of the service.
59       * @exception InitializationException if the service is unknown
60       * or can't be initialized.
61       */
62      void initService(String name) throws InitializationException;
63  
64      /***
65       * Shutdowns a Service.
66       *
67       * This method is used to release resources allocated by a
68       * Service, and return it to initial (uninitailized) state.
69       *
70       * @param name The name of the Service to be uninitialized.
71       */
72      void shutdownService(String name);
73  
74      /***
75       * Shutdowns all Services.
76       *
77       * This method is used to release resources allocated by
78       * Services, and return them to initial (uninitialized) state.
79       */
80      void shutdownServices();
81  
82      /***
83       * Returns an instance of requested Service.
84       *
85       * @param name The name of the Service requested.
86       * @return An instance of requested Service.
87       * @exception InstantiationException if the service is unknown or
88       * can't be initialized.
89       */
90      Service getService(String name) throws InstantiationException;
91  
92      /***
93       * Returns the configuration of a specific service. Services
94       * use this method to retrieve their configuration.
95       *
96       * @param name The name of the service.
97       * @return Configuration of the requested service.
98       */
99      Configuration getConfiguration(String name);
100 }