1 15 package org.apache.hivemind.definition.impl; 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.Map ; 22 23 import org.apache.hivemind.ApplicationRuntimeException; 24 import org.apache.hivemind.ClassResolver; 25 import org.apache.hivemind.Location; 26 import org.apache.hivemind.definition.ConfigurationParserDefinition; 27 import org.apache.hivemind.definition.ConfigurationPointDefinition; 28 import org.apache.hivemind.definition.ContributionDefinition; 29 import org.apache.hivemind.definition.DefinitionMessages; 30 import org.apache.hivemind.definition.ExtensionDefinition; 31 import org.apache.hivemind.definition.ModuleDefinition; 32 import org.apache.hivemind.definition.ImplementationDefinition; 33 import org.apache.hivemind.definition.InterceptorDefinition; 34 import org.apache.hivemind.definition.ServicePointDefinition; 35 import org.apache.hivemind.definition.UnresolvedExtension; 36 37 42 public class ModuleDefinitionImpl implements ModuleDefinition 43 { 44 private String _id; 45 46 private Location _location; 47 48 private String _packageName; 49 50 private ClassResolver _classResolver; 51 52 private Map _servicePoints = new HashMap (); 53 54 private Map _configurationPoints = new HashMap (); 55 56 private Collection _dependencies = new ArrayList (); 57 58 private Collection _unresolvedImplementations = new ArrayList (); 59 60 private Collection _unresolvedContributions = new ArrayList (); 61 62 private Collection _unresolvedInterceptors = new ArrayList (); 63 64 private Collection _unresolvedConfigurationParsers = new ArrayList (); 65 66 public ModuleDefinitionImpl() 67 { 68 } 69 70 77 public ModuleDefinitionImpl(String id, Location location, ClassResolver resolver, String packageName) 78 { 79 _id = id; 80 _location = location; 81 _classResolver = resolver; 82 if (packageName != null) 83 _packageName = packageName; 84 else _packageName = id; 85 } 86 87 90 public ClassResolver getClassResolver() 91 { 92 return _classResolver; 93 } 94 95 99 public void setClassResolver(ClassResolver classResolver) 100 { 101 _classResolver = classResolver; 102 } 103 104 107 public Location getLocation() 108 { 109 return _location; 110 } 111 112 115 public void setLocation(Location location) 116 { 117 _location = location; 118 } 119 120 123 public String getId() 124 { 125 return _id; 126 } 127 128 131 public void setId(String moduleId) 132 { 133 this._id = moduleId; 134 } 135 136 139 public String getPackageName() 140 { 141 return _packageName; 142 } 143 144 147 public void setPackageName(String packageName) 148 { 149 _packageName = packageName; 150 } 151 152 157 public void addServicePoint(ServicePointDefinition servicePoint) 158 { 159 if (_servicePoints.containsKey(servicePoint.getId())) { 160 throw new ApplicationRuntimeException(DefinitionMessages.duplicateServicePointId(servicePoint.getQualifiedId(), 161 this)); 162 } 163 _servicePoints.put(servicePoint.getId(), servicePoint); 164 } 165 166 169 public ServicePointDefinition getServicePoint(String id) 170 { 171 return (ServicePointDefinition) _servicePoints.get(id); 172 } 173 174 177 public Collection getServicePoints() 178 { 179 return Collections.unmodifiableCollection(_servicePoints.values()); 180 } 181 182 187 public void addConfigurationPoint(ConfigurationPointDefinition configurationPoint) 188 { 189 if (_configurationPoints.containsKey(configurationPoint.getId())) { 190 throw new ApplicationRuntimeException(DefinitionMessages.duplicateConfigurationPointId(configurationPoint.getId(), 191 this)); 192 } 193 _configurationPoints.put(configurationPoint.getId(), configurationPoint); 194 } 195 196 199 public ConfigurationPointDefinition getConfigurationPoint(String id) 200 { 201 return (ConfigurationPointDefinition) _configurationPoints.get(id); 202 } 203 204 207 public Collection getConfigurationPoints() 208 { 209 return Collections.unmodifiableCollection(_configurationPoints.values()); 210 } 211 212 215 public Collection getDependencies() 216 { 217 return Collections.unmodifiableCollection(_dependencies); 218 } 219 220 226 public void addDependency(String dependsOnModuleId) 227 { 228 _dependencies.add(dependsOnModuleId); 229 } 230 231 238 public void addImplementation(String qualifiedServicePointId, 239 ImplementationDefinition implementation) 240 { 241 UnresolvedExtension unresolvedExtension = new UnresolvedExtension(implementation, 242 qualifiedServicePointId); 243 _unresolvedImplementations.add(unresolvedExtension); 244 } 245 246 253 public void addInterceptor(String qualifiedServicePointId, 254 InterceptorDefinition interceptor) 255 { 256 UnresolvedExtension unresolvedExtension = new UnresolvedExtension(interceptor, 257 qualifiedServicePointId); 258 _unresolvedInterceptors.add(unresolvedExtension); 259 } 260 261 268 public void addContribution(String qualifiedConfigurationPointId, 269 ContributionDefinition contribution) 270 { 271 UnresolvedExtension unresolvedExtension = new UnresolvedExtension(contribution, 272 qualifiedConfigurationPointId); 273 _unresolvedContributions.add(unresolvedExtension); 274 } 275 276 283 public void addConfigurationParser(String qualifiedConfigurationPointId, ConfigurationParserDefinition parser) 284 { 285 UnresolvedExtension unresolvedExtension = new UnresolvedExtension(parser, 286 qualifiedConfigurationPointId); 287 _unresolvedConfigurationParsers.add(unresolvedExtension); 288 } 289 290 293 public Collection getContributions() 294 { 295 return _unresolvedContributions; 296 } 297 298 301 public Collection getImplementations() 302 { 303 return _unresolvedImplementations; 304 } 305 306 309 public Collection getInterceptors() 310 { 311 return _unresolvedInterceptors; 312 } 313 314 317 public Collection getConfigurationParsers() 318 { 319 return _unresolvedConfigurationParsers; 320 } 321 322 323 } 324 | Popular Tags |