From 60285be65fea3f80bfa3753baab6b0428434453c Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 20 Feb 2009 13:50:03 +0000 Subject: 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 --- .../tuscany/sca/host/webapp/WebAppServletHost.java | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'java/sca/modules') 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; } -- cgit v1.2.3