tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r689671 - in /tuscany/java/sca/modules/node-launcher-osgi: pom.xml src/main/java/org/apache/tuscany/sca/node/osgi/launcher/DomainManagerLauncher.java src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncher.java
Date Wed, 27 Aug 2008 23:44:28 GMT
Author: rfeng
Date: Wed Aug 27 16:44:27 2008
New Revision: 689671

URL: http://svn.apache.org/viewvc?rev=689671&view=rev
Log:
Additional fix for TUSCANY-2566

Modified:
    tuscany/java/sca/modules/node-launcher-osgi/pom.xml
    tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/DomainManagerLauncher.java
    tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncher.java

Modified: tuscany/java/sca/modules/node-launcher-osgi/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-launcher-osgi/pom.xml?rev=689671&r1=689670&r2=689671&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-launcher-osgi/pom.xml (original)
+++ tuscany/java/sca/modules/node-launcher-osgi/pom.xml Wed Aug 27 16:44:27 2008
@@ -111,6 +111,7 @@
                             <goal>copy-dependencies</goal>
                         </goals>
                         <configuration>
+                            <includeScope>test</includeScope>
                             <outputDirectory>${project.build.directory}/tuscany/modules</outputDirectory>
                             <overWriteReleases>true</overWriteReleases>
                             <overWriteSnapshots>true</overWriteSnapshots>

Modified: tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/DomainManagerLauncher.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/DomainManagerLauncher.java?rev=689671&r1=689670&r2=689671&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/DomainManagerLauncher.java
(original)
+++ tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/DomainManagerLauncher.java
Wed Aug 27 16:44:27 2008
@@ -31,15 +31,15 @@
  * @version $Rev$ $Date$
  */
 public class DomainManagerLauncher {
-    
-    private static final Logger logger = Logger.getLogger(DomainManagerLauncher.class.getName());
   
+
+    private static final Logger logger = Logger.getLogger(DomainManagerLauncher.class.getName());
 
     /**
      * Constructs a new DomainManagerLauncher.
      */
     private DomainManagerLauncher() {
     }
-    
+
     /**
      * Returns a new launcher instance.
      *  
@@ -58,7 +58,7 @@
     public <T> T createDomainManager() throws LauncherException {
         return (T)domainManager(".");
     }
-    
+
     /**
      * Creates a new DomainManager.
      * 
@@ -70,34 +70,41 @@
     public <T> T createDomainManager(String rootDirectory) throws LauncherException
{
         return (T)domainManager(rootDirectory);
     }
-    
+
     public static void main(String[] args) throws Exception {
         logger.info("Apache Tuscany SCA Domain Manager starting...");
 
         // Create a domain manager
         DomainManagerLauncher launcher = newInstance();
-        Object domainManager = launcher.createDomainManager();
-        
-        // Start the domain manager
-        try {
-            domainManager.getClass().getMethod("start").invoke(domainManager);
-        } catch (Exception e) {
-            logger.log(Level.SEVERE, "SCA Domain Manager could not be started", e);
-            throw e;
-        }
-        logger.info("SCA Domain Manager started.");
-        
-        logger.info("Press enter to shutdown.");
+        OSGiHost host = NodeLauncherUtil.startOSGi();
         try {
-            System.in.read();
-        } catch (IOException e) {}
 
-        // Stop the domain manager
-        try {
-            domainManager.getClass().getMethod("stop").invoke(domainManager);
-        } catch (Exception e) {
-            logger.log(Level.SEVERE, "SCA Domain Manager could not be stopped", e);
-            throw e;
+            Object domainManager = launcher.createDomainManager();
+
+            // Start the domain manager
+            try {
+                domainManager.getClass().getMethod("start").invoke(domainManager);
+            } catch (Exception e) {
+                logger.log(Level.SEVERE, "SCA Domain Manager could not be started", e);
+                throw e;
+            }
+            logger.info("SCA Domain Manager started.");
+
+            logger.info("Press enter to shutdown.");
+            try {
+                System.in.read();
+            } catch (IOException e) {
+            }
+
+            // Stop the domain manager
+            try {
+                domainManager.getClass().getMethod("stop").invoke(domainManager);
+            } catch (Exception e) {
+                logger.log(Level.SEVERE, "SCA Domain Manager could not be stopped", e);
+                throw e;
+            }
+        } finally {
+            NodeLauncherUtil.stopOSGi(host);
         }
     }
 }

Modified: tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncher.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncher.java?rev=689671&r1=689670&r2=689671&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncher.java
(original)
+++ tuscany/java/sca/modules/node-launcher-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/launcher/NodeLauncher.java
Wed Aug 27 16:44:27 2008
@@ -39,7 +39,7 @@
      */
     private NodeLauncher() {
     }
-    
+
     /**
      * Returns a new launcher instance.
      *  
@@ -61,9 +61,9 @@
     public <T> T createNodeFromURL(String configurationURL) throws LauncherException
{
         return (T)node(configurationURL, null, null, null, null);
     }
-    
+
     /**
-     * Creates a new SCA Node.
+     * Creates a new SCA OSGi Node.
      * 
      * @param compositeURI the URI of the composite to use 
      * @param contributions the URI of the contributions that provides the composites and
related 
@@ -73,12 +73,12 @@
      * @return a new SCA node.
      * @throws LauncherException
      */
-    public <T> T createNode(String compositeURI, Contribution...contributions) throws
LauncherException {
+    public <T> T createNode(String compositeURI, Contribution... contributions) throws
LauncherException {
         return (T)node(null, compositeURI, null, contributions, null);
     }
-    
+
     /**
-     * Creates a new SCA Node.
+     * Creates a new SCA OSGi Node.
      * 
      * @param compositeURI the URI of the composite to use 
      * @param compositeContent the XML content of the composite to use 
@@ -86,10 +86,11 @@
      * @return a new SCA node.
      * @throws LauncherException
      */
-    public <T> T createNode(String compositeURI, String compositeContent, Contribution...contributions)
throws LauncherException {
+    public <T> T createNode(String compositeURI, String compositeContent, Contribution...
contributions)
+        throws LauncherException {
         return (T)node(null, compositeURI, compositeContent, contributions, null);
     }
-    
+
     /**
      * Create a SCA node based on the discovery of the contribution on the classpath for
the 
      * given classloader. This method should be treated a convenient shortcut with the following
@@ -107,49 +108,57 @@
     public <T> T createNodeFromClassLoader(String compositeURI, ClassLoader classLoader)
throws LauncherException {
         return (T)node(null, compositeURI, null, null, classLoader);
     }
-    
+
     public static void main(String[] args) throws Exception {
-        logger.info("Apache Tuscany SCA Node starting...");
+        logger.info("Apache Tuscany SCA OSGi Node is starting...");
 
         // Create a node
         NodeLauncher launcher = newInstance();
-        Object node;
-        if (args.length ==1) {
-            
-            // Create from a configuration URI
-            String configurationURI = args[0];
-            logger.info("SCA Node configuration: " + configurationURI);
-            node = launcher.createNodeFromURL(configurationURI);
-        } else {
-            
-            // Create from a composite URI and a contribution location
-            String compositeURI = args[0];
-            String contributionLocation = args[1];
-            logger.info("SCA composite: " + compositeURI);
-            logger.info("SCA contribution: " + contributionLocation);
-            node = launcher.createNode(compositeURI, new Contribution("default", contributionLocation));
-        }
-        
-        // Start the node
-        try {
-            node.getClass().getMethod("start").invoke(node);
-        } catch (Exception e) {
-            logger.log(Level.SEVERE, "SCA Node could not be started", e);
-            throw e;
-        }
-        logger.info("SCA Node started.");
-        
-        logger.info("Press enter to shutdown.");
-        try {
-            System.in.read();
-        } catch (IOException e) {}
 
-        // Stop the node
+        OSGiHost host = NodeLauncherUtil.startOSGi();
         try {
-            node.getClass().getMethod("stop").invoke(node);
-        } catch (Exception e) {
-            logger.log(Level.SEVERE, "SCA Node could not be stopped", e);
-            throw e;
+
+            Object node;
+            if (args.length == 1) {
+
+                // Create from a configuration URI
+                String configurationURI = args[0];
+                logger.info("SCA OSGi Node configuration: " + configurationURI);
+                node = launcher.createNodeFromURL(configurationURI);
+            } else {
+
+                // Create from a composite URI and a contribution location
+                String compositeURI = args[0];
+                String contributionLocation = args[1];
+                logger.info("SCA composite: " + compositeURI);
+                logger.info("SCA contribution: " + contributionLocation);
+                node = launcher.createNode(compositeURI, new Contribution("default", contributionLocation));
+            }
+
+            // Start the node
+            try {
+                node.getClass().getMethod("start").invoke(node);
+            } catch (Exception e) {
+                logger.log(Level.SEVERE, "SCA OSGi Node could not be started", e);
+                throw e;
+            }
+            logger.info("SCA OSGi Node is now started.");
+
+            logger.info("Press Enter to shutdown...");
+            try {
+                System.in.read();
+            } catch (IOException e) {
+            }
+
+            // Stop the node
+            try {
+                node.getClass().getMethod("stop").invoke(node);
+            } catch (Exception e) {
+                logger.log(Level.SEVERE, "SCA OSGi Node could not be stopped", e);
+                throw e;
+            }
+        } finally {
+            NodeLauncherUtil.stopOSGi(host);
         }
     }
 



Mime
View raw message