summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
index edfb8c4a44..5808b21b37 100644
--- a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
+++ b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
@@ -19,7 +19,11 @@
package org.apache.tuscany.sca.host.webapp;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.MalformedURLException;
@@ -223,7 +227,7 @@ public class WebAppServletHost implements ServletHost {
initContextPath(config);
contributionRoot = getContributionRoot(servletContext);
NodeFactory factory = NodeFactory.newInstance();
- node = factory.createNode("WEB-INF/web.composite", new Contribution(contributionRoot, contributionRoot));
+ node = factory.createNode(contextPath, getWebComposite(servletContext), new Contribution(contributionRoot, contributionRoot));
node.start();
servletContext.setAttribute(SCA_NODE_ATTRIBUTE, node);
}
@@ -234,6 +238,29 @@ public class WebAppServletHost implements ServletHost {
}
}
+
+ protected String getWebComposite(ServletContext servletContext) throws ServletException {
+ InputStream stream = servletContext.getResourceAsStream("/WEB-INF/web.composite");
+ BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+
+ StringBuilder sb = new StringBuilder();
+ String s = null;
+ try {
+ while ((s = reader.readLine()) != null) {
+ sb.append(s + "\n");
+ }
+ } catch (IOException e) {
+ throw new ServletException(e);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ throw new ServletException(e);
+ }
+ }
+
+ return sb.toString();
+ }
protected String getContributionRoot(ServletContext servletContext) {
String contributionRoot = null;
@@ -269,6 +296,7 @@ public class WebAppServletHost implements ServletHost {
}
}
+ logger.info("contributionRoot: " + contributionRoot);
return contributionRoot;
}