// Install gravia features to the repository
ModuleClassLoader classLoader = Module.getCallerModule().getClassLoader();
Iterator<Resource> itres = classLoader.iterateResources("META-INF/environment-content", false);
while(itres.hasNext()) {
Resource modres = itres.next();
try {
InputStream input = modres.openStream();
RepositoryReader reader = new DefaultRepositoryXMLReader(input);
org.jboss.gravia.resource.Resource xmlres = reader.nextResource();
while (xmlres != null) {
if (environment.getResource(xmlres.getIdentity()) == null) {
DefaultResourceBuilder builder = new DefaultResourceBuilder();
for (Capability cap : xmlres.getCapabilities(null)) {
builder.addCapability(cap.getNamespace(), cap.getAttributes(), cap.getDirectives());
}
for (Requirement req : xmlres.getRequirements(null)) {
builder.addCapability(req.getNamespace(), req.getAttributes(), req.getDirectives());
}
environment.addResource(builder.getResource());
}
xmlres = reader.nextResource();
}
} catch (IOException e) {
throw new IllegalStateException("Cannot install resource to environment: " + modres.getName());
}
}
}