}
}
@SuppressWarnings("unchecked")
private static NodeConfiguration getNodeConfiguration(ServletContext servletContext) throws IOException {
NodeConfiguration configuration = null;
String nodeConfigURI = servletContext.getInitParameter("node.configuration");
if (nodeConfigURI != null) {
configuration = factory.loadConfiguration(openStream(servletContext, nodeConfigURI));
} else {
configuration = factory.createNodeConfiguration();
Enumeration<String> names = servletContext.getInitParameterNames();
while (names.hasMoreElements()) {
String name = names.nextElement();
if (name.startsWith("contribution.")) {
String contrib = servletContext.getInitParameter(name);
if (contrib != null) {
configuration.addContribution(getResource(servletContext, contrib));
}
}
}
if (configuration.getContributions().isEmpty()) {
// TODO: Which path should be the default root
configuration.addContribution(getResource(servletContext, "/"));
}
URL composite = getResource(servletContext, "/WEB-INF/web.composite");
if (composite != null) {
configuration.getContributions().get(0).addDeploymentComposite(composite);
}
String nodeURI = servletContext.getInitParameter("node.uri");
if (nodeURI == null) {
nodeURI = new File(servletContext.getRealPath("/")).getName();
}
configuration.setURI(nodeURI);
String domainURI = servletContext.getInitParameter("domain.uri");
if (domainURI != null) {
configuration.setDomainURI(domainURI);
}
}
return configuration;
}