summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-04-25 21:22:43 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-04-25 21:22:43 +0000
commit61fe29b688ffd6097149126dfcb8101f470d9dc5 (patch)
treed9d927bc231ae787463fcf359155ef33d65ced51 /sca-java-2.x
parentfd0eee20f49a36074b408179ec973146700a0252 (diff)
Update webapp host to support a contribution init param pointing to a folder as well as an individual contribution
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@937880 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
index 6f2135ef50..ec8ead0b7a 100644
--- a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
+++ b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.host.webapp;
import java.io.File;
import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Enumeration;
@@ -64,7 +65,7 @@ public class WebAppHelper {
}
@SuppressWarnings("unchecked")
- private static NodeConfiguration getNodeConfiguration(ServletContext servletContext) throws IOException {
+ private static NodeConfiguration getNodeConfiguration(ServletContext servletContext) throws IOException, URISyntaxException {
NodeConfiguration configuration = null;
String nodeConfigURI = (String) servletContext.getAttribute("node.configuration");
if (nodeConfigURI != null) {
@@ -75,13 +76,21 @@ public class WebAppHelper {
Enumeration<String> names = servletContext.getAttributeNames();
while (names.hasMoreElements()) {
String name = names.nextElement();
- if (name.startsWith("contribution.")) {
+ if (name.startsWith("contribution")) {
String contrib = (String) servletContext.getAttribute(name);
if (contrib != null) {
- configuration.addContribution(getResource(servletContext, contrib));
+ File f = new File(getResource(servletContext, contrib).toURI());
+ if (f.isDirectory()) {
+ for (File n : f.listFiles()) {
+ configuration.addContribution(n.toURI().toURL());
+ }
+ } else {
+ configuration.addContribution(f.toURI().toURL());
+ }
}
}
}
+
if (configuration.getContributions().isEmpty()) {
// TODO: Which path should be the default root
configuration.addContribution(getResource(servletContext, "/"));
@@ -138,8 +147,8 @@ public class WebAppHelper {
servletHosts.setWebApp(true);
// TODO: why are the init parameters copied to the attributes?
- for (Enumeration<String> e = servletContext.getInitParameterNames(); e.hasMoreElements();) {
- String name = e.nextElement();
+ for (Enumeration<?> e = servletContext.getInitParameterNames(); e.hasMoreElements();) {
+ String name = (String)e.nextElement();
String value = servletContext.getInitParameter(name);
servletContext.setAttribute(name, value);
}
@@ -196,6 +205,8 @@ public class WebAppHelper {
configuration = getNodeConfiguration(servletContext);
} catch (IOException e) {
throw new ServletException(e);
+ } catch (URISyntaxException e) {
+ throw new ServletException(e);
}
Node node = factory.createNode(configuration).start();
return node;