diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-20 13:50:03 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-20 13:50:03 +0000 |
commit | 60285be65fea3f80bfa3753baab6b0428434453c (patch) | |
tree | 95782db104fdde3bc5ec214194936dce2d573ee6 /java/sca/modules/host-webapp/src | |
parent | b2721aef204ec76b12e1fe331ccf04ec4fb7ee3c (diff) |
Update so webapp runtime works with web-inf/web.composite
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@746239 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/host-webapp/src')
-rw-r--r-- | java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java | 30 |
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; } |