composite.setName(reader.getAttributeValue(null, "name"));
boolean done = false;
while (!done) {
switch (reader.next()) {
case START_ELEMENT:
ModelObject o = registry.load(parent, reader, deploymentContext);
if (o instanceof ServiceDefinition) {
composite.add((ServiceDefinition) o);
} else if (o instanceof ReferenceDefinition) {
composite.add((ReferenceDefinition) o);
} else if (o instanceof Property<?>) {
composite.add((Property<?>) o);
} else if (o instanceof ComponentDefinition<?>) {
composite.add((ComponentDefinition<? extends Implementation<?>>) o);
} else if (o instanceof Include) {
composite.add((Include) o);
} else if (o instanceof Dependency) {
Artifact artifact = ((Dependency) o).getArtifact();
if (artifactRepository != null) {
// default to jar type if not specified
if (artifact.getType() == null) {
artifact.setType("jar");
}
artifactRepository.resolve(artifact);
}
if (artifact.getUrl() != null) {
ClassLoader classLoader = deploymentContext.getClassLoader();
if (classLoader instanceof CompositeClassLoader) {
CompositeClassLoader ccl = (CompositeClassLoader)classLoader;
for (URL dep : artifact.getUrls()) {
ccl.addURL(dep);
}
}
}
} else {
// HACK: [rfeng] Add as an unknown model extension
if (o != null) {
composite.getExtensions().put(o.getClass(), o);
}
}
reader.next();
break;
case END_ELEMENT: