1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.hivemind.parse; |
16 |
| |
17 |
| import java.util.ArrayList; |
18 |
| import java.util.Collection; |
19 |
| import java.util.Collections; |
20 |
| import java.util.HashMap; |
21 |
| import java.util.List; |
22 |
| import java.util.Map; |
23 |
| |
24 |
| import org.apache.commons.logging.Log; |
25 |
| import org.apache.commons.logging.LogFactory; |
26 |
| import org.apache.hivemind.ClassResolver; |
27 |
| import org.apache.hivemind.ErrorHandler; |
28 |
| import org.apache.hivemind.schema.Schema; |
29 |
| import org.apache.hivemind.schema.impl.SchemaImpl; |
30 |
| import org.apache.hivemind.util.ToStringBuilder; |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| public final class ModuleDescriptor extends BaseAnnotationHolder |
40 |
| { |
41 |
| |
42 |
| private static final Log LOG = LogFactory.getLog(ModuleDescriptor.class); |
43 |
| |
44 |
| private String _moduleId; |
45 |
| |
46 |
| private String _version; |
47 |
| |
48 |
| |
49 |
| |
50 |
| private String _packageName; |
51 |
| |
52 |
| private List _servicePoints; |
53 |
| |
54 |
| private List _implementations; |
55 |
| |
56 |
| private List _configurationPoints; |
57 |
| |
58 |
| private List _contributions; |
59 |
| |
60 |
| private List _subModules; |
61 |
| |
62 |
| private List _dependencies; |
63 |
| |
64 |
| |
65 |
| private Map _schemas; |
66 |
| |
67 |
| private ClassResolver _resolver; |
68 |
| |
69 |
| |
70 |
| private ErrorHandler _errorHandler; |
71 |
| |
72 |
301
| public ModuleDescriptor(ClassResolver resolver, ErrorHandler errorHandler)
|
73 |
| { |
74 |
301
| _resolver = resolver;
|
75 |
301
| _errorHandler = errorHandler;
|
76 |
| } |
77 |
| |
78 |
28
| public String toString()
|
79 |
| { |
80 |
28
| ToStringBuilder builder = new ToStringBuilder(this);
|
81 |
| |
82 |
28
| builder.append("moduleId", _moduleId);
|
83 |
28
| builder.append("version", _version);
|
84 |
| |
85 |
28
| return builder.toString();
|
86 |
| } |
87 |
| |
88 |
2640
| public void addServicePoint(ServicePointDescriptor service)
|
89 |
| { |
90 |
2640
| if (_servicePoints == null)
|
91 |
220
| _servicePoints = new ArrayList();
|
92 |
| |
93 |
2640
| _servicePoints.add(service);
|
94 |
| } |
95 |
| |
96 |
271
| public List getServicePoints()
|
97 |
| { |
98 |
271
| return _servicePoints;
|
99 |
| } |
100 |
| |
101 |
16
| public void addImplementation(ImplementationDescriptor descriptor)
|
102 |
| { |
103 |
16
| if (_implementations == null)
|
104 |
16
| _implementations = new ArrayList();
|
105 |
| |
106 |
16
| _implementations.add(descriptor);
|
107 |
| } |
108 |
| |
109 |
267
| public List getImplementations()
|
110 |
| { |
111 |
267
| return _implementations;
|
112 |
| } |
113 |
| |
114 |
1087
| public void addConfigurationPoint(ConfigurationPointDescriptor descriptor)
|
115 |
| { |
116 |
1087
| if (_configurationPoints == null)
|
117 |
202
| _configurationPoints = new ArrayList();
|
118 |
| |
119 |
1087
| _configurationPoints.add(descriptor);
|
120 |
| } |
121 |
| |
122 |
274
| public List getConfigurationPoints()
|
123 |
| { |
124 |
274
| return _configurationPoints;
|
125 |
| } |
126 |
| |
127 |
712
| public void addContribution(ContributionDescriptor descriptor)
|
128 |
| { |
129 |
712
| if (_contributions == null)
|
130 |
194
| _contributions = new ArrayList();
|
131 |
| |
132 |
712
| _contributions.add(descriptor);
|
133 |
| } |
134 |
| |
135 |
268
| public List getContributions()
|
136 |
| { |
137 |
268
| return _contributions;
|
138 |
| } |
139 |
| |
140 |
3
| public void addSubModule(SubModuleDescriptor subModule)
|
141 |
| { |
142 |
3
| if (_subModules == null)
|
143 |
3
| _subModules = new ArrayList();
|
144 |
| |
145 |
3
| _subModules.add(subModule);
|
146 |
| } |
147 |
| |
148 |
254
| public List getSubModules()
|
149 |
| { |
150 |
254
| return _subModules;
|
151 |
| } |
152 |
| |
153 |
13
| public void addDependency(DependencyDescriptor dependency)
|
154 |
| { |
155 |
13
| if (_dependencies == null)
|
156 |
13
| _dependencies = new ArrayList();
|
157 |
| |
158 |
13
| _dependencies.add(dependency);
|
159 |
| } |
160 |
| |
161 |
268
| public List getDependencies()
|
162 |
| { |
163 |
268
| return _dependencies;
|
164 |
| } |
165 |
| |
166 |
| |
167 |
| |
168 |
| |
169 |
| |
170 |
| |
171 |
| |
172 |
335
| public void addSchema(SchemaImpl schema)
|
173 |
| { |
174 |
335
| if (_schemas == null)
|
175 |
189
| _schemas = new HashMap();
|
176 |
| |
177 |
335
| String schemaId = schema.getId();
|
178 |
| |
179 |
335
| Schema existing = getSchema(schemaId);
|
180 |
| |
181 |
335
| if (existing != null)
|
182 |
| { |
183 |
1
| _errorHandler.error(LOG, ParseMessages.duplicateSchema(
|
184 |
| _moduleId + '.' + schemaId, |
185 |
| existing), schema.getLocation(), null); |
186 |
1
| return;
|
187 |
| } |
188 |
| |
189 |
334
| _schemas.put(schemaId, schema);
|
190 |
| } |
191 |
| |
192 |
| |
193 |
340
| public Schema getSchema(String id)
|
194 |
| { |
195 |
340
| return _schemas == null ? null : (Schema) _schemas.get(id);
|
196 |
| } |
197 |
| |
198 |
| |
199 |
| |
200 |
| |
201 |
| |
202 |
| |
203 |
264
| public Collection getSchemas()
|
204 |
| { |
205 |
264
| return _schemas != null ? _schemas.values() : Collections.EMPTY_LIST;
|
206 |
| } |
207 |
| |
208 |
1857
| public String getModuleId()
|
209 |
| { |
210 |
1857
| return _moduleId;
|
211 |
| } |
212 |
| |
213 |
9
| public String getVersion()
|
214 |
| { |
215 |
9
| return _version;
|
216 |
| } |
217 |
| |
218 |
300
| public void setModuleId(String string)
|
219 |
| { |
220 |
300
| _moduleId = string;
|
221 |
| } |
222 |
| |
223 |
291
| public void setVersion(String string)
|
224 |
| { |
225 |
291
| _version = string;
|
226 |
| } |
227 |
| |
228 |
257
| public ClassResolver getClassResolver()
|
229 |
| { |
230 |
257
| return _resolver;
|
231 |
| } |
232 |
| |
233 |
| |
234 |
| |
235 |
| |
236 |
| |
237 |
| |
238 |
| |
239 |
| |
240 |
2904
| public String getPackageName()
|
241 |
| { |
242 |
2904
| return _packageName;
|
243 |
| } |
244 |
| |
245 |
| |
246 |
| |
247 |
283
| public void setPackageName(String packageName)
|
248 |
| { |
249 |
283
| _packageName = packageName;
|
250 |
| } |
251 |
| } |