%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.BaseService |
|
|
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 java.util.Properties; |
|
20 | ||
21 | import org.apache.commons.configuration.Configuration; |
|
22 | import org.apache.commons.configuration.ConfigurationConverter; |
|
23 | ||
24 | /** |
|
25 | * This class is a generic implementation of <code>Service</code>. |
|
26 | * |
|
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:hps@intermeta.de">Henning P. Schmiedehausen</a> |
|
30 | * @version $Id: BaseService.java 264148 2005-08-29 14:21:04Z henning $ |
|
31 | */ |
|
32 | 396 | public class BaseService |
33 | extends BaseInitable |
|
34 | implements Service |
|
35 | { |
|
36 | /** A reference to the ServiceBroker that instantiated this object. */ |
|
37 | protected ServiceBroker serviceBroker; |
|
38 | ||
39 | /** The configuration for this service */ |
|
40 | protected Configuration configuration; |
|
41 | ||
42 | /** The name of this Service. */ |
|
43 | protected String name; |
|
44 | ||
45 | /** |
|
46 | * Saves a reference to the ServiceBroker that instantiated this |
|
47 | * object, so that it can ask for its properties and access other |
|
48 | * Services. |
|
49 | * |
|
50 | * @param broker The ServiceBroker that instantiated this object. |
|
51 | */ |
|
52 | public void setServiceBroker(ServiceBroker broker) |
|
53 | { |
|
54 | 396 | this.serviceBroker = broker; |
55 | 396 | } |
56 | ||
57 | /** |
|
58 | * ServiceBroker uses this method to pass a Service its name. |
|
59 | * |
|
60 | * @param name The name of this Service. |
|
61 | */ |
|
62 | public void setName(String name) |
|
63 | { |
|
64 | 396 | this.name = name; |
65 | 396 | } |
66 | ||
67 | /** |
|
68 | * Returns the name of this service. |
|
69 | * |
|
70 | * @return The name of this Service. |
|
71 | */ |
|
72 | public String getName() |
|
73 | { |
|
74 | 0 | return name; |
75 | } |
|
76 | ||
77 | /** |
|
78 | * Returns a ServiceBroker reference. |
|
79 | * |
|
80 | * @return The ServiceBroker that instantiated this object. |
|
81 | */ |
|
82 | public ServiceBroker getServiceBroker() |
|
83 | { |
|
84 | 358 | return serviceBroker; |
85 | } |
|
86 | ||
87 | /** |
|
88 | * Returns the properties of this Service. |
|
89 | * |
|
90 | * @return The Properties of this Service. |
|
91 | */ |
|
92 | public Properties getProperties() |
|
93 | { |
|
94 | 0 | return ConfigurationConverter.getProperties(getConfiguration()); |
95 | } |
|
96 | ||
97 | /** |
|
98 | * Returns the configuration of this Service. |
|
99 | * |
|
100 | * @return The Configuration of this Service. |
|
101 | */ |
|
102 | public Configuration getConfiguration() |
|
103 | { |
|
104 | 712 | if (name == null) |
105 | { |
|
106 | 0 | return null; |
107 | } |
|
108 | ||
109 | 712 | if (configuration == null) |
110 | { |
|
111 | 358 | configuration = getServiceBroker().getConfiguration(name); |
112 | } |
|
113 | 712 | return configuration; |
114 | } |
|
115 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |