|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ModuleDescriptor.java | 80% | 100% | 100% | 95.4% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.hivemind.parse;
|
|
16 |
|
|
17 |
import java.util.ArrayList;
|
|
18 |
import java.util.Collection;
|
|
19 |
import java.util.HashMap;
|
|
20 |
import java.util.List;
|
|
21 |
import java.util.Map;
|
|
22 |
|
|
23 |
import org.apache.commons.logging.Log;
|
|
24 |
import org.apache.commons.logging.LogFactory;
|
|
25 |
import org.apache.hivemind.ClassResolver;
|
|
26 |
import org.apache.hivemind.ErrorHandler;
|
|
27 |
import org.apache.hivemind.schema.Schema;
|
|
28 |
import org.apache.hivemind.util.ToStringBuilder;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* Representation of a HiveMind module descriptor, as parsed by
|
|
32 |
* {@link org.apache.hivemind.parse.DescriptorParser}. Corresponds to the root <module>
|
|
33 |
* element.
|
|
34 |
*
|
|
35 |
* @author Howard Lewis Ship
|
|
36 |
*/
|
|
37 |
public final class ModuleDescriptor extends BaseAnnotationHolder |
|
38 |
{ |
|
39 |
/** @since 1.1 */
|
|
40 |
private static final Log LOG = LogFactory.getLog(ModuleDescriptor.class); |
|
41 |
|
|
42 |
private String _moduleId;
|
|
43 |
|
|
44 |
private String _version;
|
|
45 |
|
|
46 |
private List _servicePoints;
|
|
47 |
|
|
48 |
private List _implementations;
|
|
49 |
|
|
50 |
private List _configurationPoints;
|
|
51 |
|
|
52 |
private List _contributions;
|
|
53 |
|
|
54 |
private List _subModules;
|
|
55 |
|
|
56 |
private List _dependencies;
|
|
57 |
|
|
58 |
/** @since 1.1 */
|
|
59 |
private Map _schemas;
|
|
60 |
|
|
61 |
private ClassResolver _resolver;
|
|
62 |
|
|
63 |
/** @since 1.1 */
|
|
64 |
private ErrorHandler _errorHandler;
|
|
65 |
|
|
66 | 259 |
public ModuleDescriptor(ClassResolver resolver, ErrorHandler errorHandler)
|
67 |
{ |
|
68 | 259 |
_resolver = resolver; |
69 | 259 |
_errorHandler = errorHandler; |
70 |
} |
|
71 |
|
|
72 | 28 |
public String toString()
|
73 |
{ |
|
74 | 28 |
ToStringBuilder builder = new ToStringBuilder(this); |
75 |
|
|
76 | 28 |
builder.append("moduleId", _moduleId);
|
77 | 28 |
builder.append("version", _version);
|
78 |
|
|
79 | 28 |
return builder.toString();
|
80 |
} |
|
81 |
|
|
82 | 1718 |
public void addServicePoint(ServicePointDescriptor service) |
83 |
{ |
|
84 | 1718 |
if (_servicePoints == null) |
85 | 181 |
_servicePoints = new ArrayList();
|
86 |
|
|
87 | 1718 |
_servicePoints.add(service); |
88 |
} |
|
89 |
|
|
90 | 231 |
public List getServicePoints()
|
91 |
{ |
|
92 | 231 |
return _servicePoints;
|
93 |
} |
|
94 |
|
|
95 | 16 |
public void addImplementation(ImplementationDescriptor descriptor) |
96 |
{ |
|
97 | 16 |
if (_implementations == null) |
98 | 16 |
_implementations = new ArrayList();
|
99 |
|
|
100 | 16 |
_implementations.add(descriptor); |
101 |
} |
|
102 |
|
|
103 | 229 |
public List getImplementations()
|
104 |
{ |
|
105 | 229 |
return _implementations;
|
106 |
} |
|
107 |
|
|
108 | 924 |
public void addConfigurationPoint(ConfigurationPointDescriptor descriptor) |
109 |
{ |
|
110 | 924 |
if (_configurationPoints == null) |
111 | 179 |
_configurationPoints = new ArrayList();
|
112 |
|
|
113 | 924 |
_configurationPoints.add(descriptor); |
114 |
} |
|
115 |
|
|
116 | 235 |
public List getConfigurationPoints()
|
117 |
{ |
|
118 | 235 |
return _configurationPoints;
|
119 |
} |
|
120 |
|
|
121 | 611 |
public void addContribution(ContributionDescriptor descriptor) |
122 |
{ |
|
123 | 611 |
if (_contributions == null) |
124 | 173 |
_contributions = new ArrayList();
|
125 |
|
|
126 | 611 |
_contributions.add(descriptor); |
127 |
} |
|
128 |
|
|
129 | 230 |
public List getContributions()
|
130 |
{ |
|
131 | 230 |
return _contributions;
|
132 |
} |
|
133 |
|
|
134 | 3 |
public void addSubModule(SubModuleDescriptor subModule) |
135 |
{ |
|
136 | 3 |
if (_subModules == null) |
137 | 3 |
_subModules = new ArrayList();
|
138 |
|
|
139 | 3 |
_subModules.add(subModule); |
140 |
} |
|
141 |
|
|
142 | 216 |
public List getSubModules()
|
143 |
{ |
|
144 | 216 |
return _subModules;
|
145 |
} |
|
146 |
|
|
147 | 13 |
public void addDependency(DependencyDescriptor dependency) |
148 |
{ |
|
149 | 13 |
if (_dependencies == null) |
150 | 13 |
_dependencies = new ArrayList();
|
151 |
|
|
152 | 13 |
_dependencies.add(dependency); |
153 |
} |
|
154 |
|
|
155 | 230 |
public List getDependencies()
|
156 |
{ |
|
157 | 230 |
return _dependencies;
|
158 |
} |
|
159 |
|
|
160 |
/**
|
|
161 |
* Adds a schema to this module descriptor. If a schema with the same id already has been added,
|
|
162 |
* an error is reported and the given schema is ignored.
|
|
163 |
*
|
|
164 |
* @since 1.1
|
|
165 |
*/
|
|
166 | 294 |
public void addSchema(Schema schema) |
167 |
{ |
|
168 | 294 |
if (_schemas == null) |
169 | 168 |
_schemas = new HashMap();
|
170 |
|
|
171 | 294 |
String schemaId = schema.getId(); |
172 |
|
|
173 | 294 |
Schema existing = getSchema(schemaId); |
174 |
|
|
175 | 294 |
if (existing != null) |
176 |
{ |
|
177 | 1 |
_errorHandler.error(LOG, ParseMessages.duplicateSchema( |
178 |
_moduleId + '.' + schemaId, |
|
179 |
existing), schema.getLocation(), null);
|
|
180 | 1 |
return;
|
181 |
} |
|
182 |
|
|
183 | 293 |
_schemas.put(schemaId, schema); |
184 |
} |
|
185 |
|
|
186 |
/** @since 1.1 */
|
|
187 | 299 |
public Schema getSchema(String id)
|
188 |
{ |
|
189 | 299 |
return _schemas == null ? null : (Schema) _schemas.get(id); |
190 |
} |
|
191 |
|
|
192 |
/** @since 1.1 */
|
|
193 | 370 |
public Collection getSchemas()
|
194 |
{ |
|
195 | 370 |
return _schemas != null ? _schemas.values() : null; |
196 |
} |
|
197 |
|
|
198 | 1783 |
public String getModuleId()
|
199 |
{ |
|
200 | 1783 |
return _moduleId;
|
201 |
} |
|
202 |
|
|
203 | 9 |
public String getVersion()
|
204 |
{ |
|
205 | 9 |
return _version;
|
206 |
} |
|
207 |
|
|
208 | 258 |
public void setModuleId(String string) |
209 |
{ |
|
210 | 258 |
_moduleId = string; |
211 |
} |
|
212 |
|
|
213 | 249 |
public void setVersion(String string) |
214 |
{ |
|
215 | 249 |
_version = string; |
216 |
} |
|
217 |
|
|
218 | 219 |
public ClassResolver getClassResolver()
|
219 |
{ |
|
220 | 219 |
return _resolver;
|
221 |
} |
|
222 |
|
|
223 |
} |
|