You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2007/10/30 17:55:59 UTC

svn commit: r590148 - /incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java

Author: antelder
Date: Tue Oct 30 09:55:58 2007
New Revision: 590148

URL: http://svn.apache.org/viewvc?rev=590148&view=rev
Log:
Restore ability to hot deploy contributions to a running node

Modified:
    incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java

Modified: incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java?rev=590148&r1=590147&r2=590148&view=diff
==============================================================================
--- incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java (original)
+++ incubator/tuscany/java/sca/distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/WarContextListener.java Tue Oct 30 09:55:58 2007
@@ -21,7 +21,6 @@
 
 import java.io.File;
 import java.io.FilenameFilter;
-import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -37,21 +36,15 @@
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
-import org.apache.tuscany.sca.contribution.service.ContributionException;
-import org.apache.tuscany.sca.core.assembly.ActivationException;
 import org.apache.tuscany.sca.domain.SCADomain;
 import org.apache.tuscany.sca.node.NodeException;
 import org.apache.tuscany.sca.node.SCANode;
 import org.apache.tuscany.sca.node.SCANodeFactory;
-import org.apache.tuscany.sca.node.impl.SCANodeImpl;
 
 /**
  * A ServletContextListener for the Tuscany WAR distribution.
  * 
  * Starts and stops a Tuscany SCA domain Node for the webapp. 
- * 
- * TODO: Use Node instead of NodeImpl?
  */
 public class WarContextListener implements ServletContextListener {
     private final static Logger logger = Logger.getLogger(WarContextListener.class.getName());
@@ -105,32 +98,25 @@
         }
     }
 
-    protected void initNode() throws ContributionException, ActivationException, IOException,
-        CompositeBuilderException, URISyntaxException {
-        try {
-            logger.log(Level.INFO, "SCA node starting");
-    
-            classLoader = new AddableURLClassLoader(new URL[] {}, Thread.currentThread().getContextClassLoader());
-            Thread.currentThread().setContextClassLoader(classLoader);
-            
-            SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
-            node = nodeFactory.createSCANode(nodeName, domainName);
-            domain = node.getDomain();
-            
-    
-            existingContributions = new HashMap<URL, Long>();
-            URL[] contributions = getContributionJarURLs(repository);
-            for (URL contribution : contributions) {
-                    addContribution(contribution);
-            }
-            
-            node.start();
-    
-            initHotDeploy(repository);
-        } catch (Throwable e) {
-            e.printStackTrace();
-            logger.log(Level.WARNING, "Exception adding contribution: " + e);
+    protected void initNode() throws NodeException, URISyntaxException {
+        logger.log(Level.INFO, "SCA node starting");
+        
+        classLoader = new AddableURLClassLoader(new URL[] {}, Thread.currentThread().getContextClassLoader());
+        Thread.currentThread().setContextClassLoader(classLoader);
+        
+        SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+        node = nodeFactory.createSCANode(nodeName, domainName);
+        domain = node.getDomain();
+
+        existingContributions = new HashMap<URL, Long>();
+        URL[] contributions = getContributionJarURLs(repository);
+        for (URL contribution : contributions) {
+                addContribution(contribution);
         }
+        
+        node.start();
+
+        initHotDeploy(repository);
     }
 
     protected void addContribution(URL contribution) throws URISyntaxException, NodeException {
@@ -195,9 +181,18 @@
         for (URL contribution : addedContributions) {
             try {
                 addContribution(contribution);
+                node.startContribution(contribution.toString());
             } catch (Throwable e) {
                 e.printStackTrace();
                 logger.log(Level.WARNING, "Exception adding contribution: " + e);
+            }
+        }
+        if (addedContributions.size() > 0) {
+            try {
+                node.start();
+            } catch (NodeException e) {
+                e.printStackTrace();
+                logger.log(Level.WARNING, "Exception restarting node for added contributions: " + e);
             }
         }
         



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org