tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r746239 - /tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
Date Fri, 20 Feb 2009 13:50:03 GMT
Author: antelder
Date: Fri Feb 20 13:50:03 2009
New Revision: 746239

URL: http://svn.apache.org/viewvc?rev=746239&view=rev
Log:
Update so webapp runtime works with web-inf/web.composite

Modified:
    tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java

Modified: tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java?rev=746239&r1=746238&r2=746239&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
(original)
+++ tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
Fri Feb 20 13:50:03 2009
@@ -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 @@
             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 @@
         }
         
     }
+    
+    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 @@
             }
         }
 
+        logger.info("contributionRoot: " + contributionRoot);
         return contributionRoot;
     }
 



Mime
View raw message