in gshell/gshell-features/src/main/java/org/apache/servicemix/kernel/gshell/features/internal/RepositoryImpl.java [82:150]
public void load() throws IOException {
try {
repositories = new ArrayList<URI>();
features = new ArrayList<Feature>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document doc = factory.newDocumentBuilder().parse(uri.toURL().openStream());
NodeList nodes = doc.getDocumentElement().getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (!(node instanceof Element)) {
continue;
}
if ("repository".equals(node.getNodeName())) {
Element e = (Element) nodes.item(i);
repositories.add(new URI(e.getTextContent()));
} else if ("feature".equals(node.getNodeName())) {
Element e = (Element) nodes.item(i);
String name = e.getAttribute("name");
String version = e.getAttribute("version");
FeatureImpl f;
if (version != null && version.length() > 0) {
f = new FeatureImpl(name, version);
} else {
f = new FeatureImpl(name);
}
NodeList featureNodes = e.getElementsByTagName("feature");
for (int j = 0; j < featureNodes.getLength(); j++) {
Element b = (Element) featureNodes.item(j);
String dependencyFeatureVersion = b.getAttribute("version");
if (dependencyFeatureVersion != null && dependencyFeatureVersion.length() > 0) {
f.addDependency(new FeatureImpl(b.getTextContent(), dependencyFeatureVersion));
} else {
f.addDependency(new FeatureImpl(b.getTextContent()));
}
}
NodeList configNodes = e.getElementsByTagName("config");
for (int j = 0; j < configNodes.getLength(); j++) {
Element c = (Element) configNodes.item(j);
String cfgName = c.getAttribute("name");
String data = c.getTextContent();
Properties properties = new Properties();
properties.load(new ByteArrayInputStream(data.getBytes()));
interpolation(properties);
Map<String, String> hashtable = new Hashtable<String, String>();
for (Object key : properties.keySet()) {
String n = key.toString();
hashtable.put(n, properties.getProperty(n));
}
f.addConfig(cfgName, hashtable);
}
NodeList bundleNodes = e.getElementsByTagName("bundle");
for (int j = 0; j < bundleNodes.getLength(); j++) {
Element b = (Element) bundleNodes.item(j);
f.addBundle(b.getTextContent());
}
features.add(f);
}
}
} catch (SAXException e) {
throw (IOException) new IOException().initCause(e);
} catch (ParserConfigurationException e) {
throw (IOException) new IOException().initCause(e);
} catch (URISyntaxException e) {
throw (IOException) new IOException(e.getMessage() + " : " + uri).initCause(e);
} catch (IllegalArgumentException e) {
throw (IOException) new IOException(e.getMessage() + " : " + uri).initCause(e);
}
}