Author: slaws
Date: Fri Nov 20 12:10:03 2009
New Revision: 882529

URL: http://svn.apache.org/viewvc?rev=882529&view=rev
Log:
Bring up 1.x and 2.x together. 

Added:
    tuscany/sandbox/slaws/runtimecompat/1xbundle/src/
    tuscany/sandbox/slaws/runtimecompat/1xbundle/src/main/
    tuscany/sandbox/slaws/runtimecompat/1xbundle/src/main/resources/
    tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/java/calculator/
    
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/java/calculator/CalculatorService.java
   (with props)
    tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/
    
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/logging.properties
   (with props)
    tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/calculator/
    
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/calculator/CalculatorService.java
   (with props)
Modified:
    tuscany/sandbox/slaws/runtimecompat/1xlauncher/pom.xml
    tuscany/sandbox/slaws/runtimecompat/2xlauncher/pom.xml
    
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/launcher/TwoXLauncher.java
    
tuscany/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java
    tuscany/sandbox/slaws/runtimecompat/pom.xml

Modified: tuscany/sandbox/slaws/runtimecompat/1xlauncher/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/runtimecompat/1xlauncher/pom.xml?rev=882529&r1=882528&r2=882529&view=diff
==============================================================================
--- tuscany/sandbox/slaws/runtimecompat/1xlauncher/pom.xml (original)
+++ tuscany/sandbox/slaws/runtimecompat/1xlauncher/pom.xml Fri Nov 20 12:10:03 
2009
@@ -58,7 +58,7 @@
     </dependencies>
     
     <build>
-       <finalName>${artifactId}</finalName>
+       <!-- finalName>${artifactId}</finalName-->
         <plugins> 
             
             <plugin>    

Added: 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/java/calculator/CalculatorService.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/java/calculator/CalculatorService.java?rev=882529&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/java/calculator/CalculatorService.java
 (added)
+++ 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/java/calculator/CalculatorService.java
 Fri Nov 20 12:10:03 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package calculator;
+
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+    double add(double n1, double n2);
+
+    double subtract(double n1, double n2);
+
+    double multiply(double n1, double n2);
+
+    double divide(double n1, double n2);
+
+}

Propchange: 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/java/calculator/CalculatorService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/java/calculator/CalculatorService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/logging.properties
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/logging.properties?rev=882529&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/logging.properties
 (added)
+++ 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/logging.properties
 Fri Nov 20 12:10:03 2009
@@ -0,0 +1,56 @@
+############################################################
+#      Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.  
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+#      Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler 
+# classes.  These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers.  For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+.level= INFO
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.limit = 50000
+java.util.logging.FileHandler.count = 1
+java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to INFO and above.
+java.util.logging.ConsoleHandler.level = INFO
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+# For example, set the com.xyz.foo logger to only log SEVERE
+# messages:
+com.xyz.foo.level = SEVERE
+
+org.apache.tuscany.sca.level = FINE

Propchange: 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/logging.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/logging.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
tuscany/sandbox/slaws/runtimecompat/1xlauncher/src/main/resources/logging.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: tuscany/sandbox/slaws/runtimecompat/2xlauncher/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/runtimecompat/2xlauncher/pom.xml?rev=882529&r1=882528&r2=882529&view=diff
==============================================================================
--- tuscany/sandbox/slaws/runtimecompat/2xlauncher/pom.xml (original)
+++ tuscany/sandbox/slaws/runtimecompat/2xlauncher/pom.xml Fri Nov 20 12:10:03 
2009
@@ -27,6 +27,7 @@
     <version>1.0-SNAPSHOT</version>
     <artifactId>2x-launcher</artifactId>
     <name>Apache Tuscany SCA 2.x Launcher</name>
+    <packaging>bundle</packaging> 
 
     <dependencies>
         <dependency>
@@ -58,6 +59,22 @@
     </dependencies>
     
     <build>
-       <finalName>${artifactId}</finalName>
+       <!-- finalName>${artifactId}</finalName-->
+        <plugins> 
+            
+            <plugin>    
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                       <configuration>
+                         <instructions>
+                           
<Import-Package>org.apache.tuscany.sca.node;version="[2.0.0,2.0.0]"</Import-Package>
+                           <Export-Package>launcher</Export-Package>
+                           
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                         </instructions>
+                       </configuration>
+           </plugin> 
+
+        </plugins>        
     </build>
 </project>

Added: 
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/calculator/CalculatorService.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/calculator/CalculatorService.java?rev=882529&view=auto
==============================================================================
--- 
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/calculator/CalculatorService.java
 (added)
+++ 
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/calculator/CalculatorService.java
 Fri Nov 20 12:10:03 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package calculator;
+
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+    double add(double n1, double n2);
+
+    double subtract(double n1, double n2);
+
+    double multiply(double n1, double n2);
+
+    double divide(double n1, double n2);
+
+}

Propchange: 
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/calculator/CalculatorService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/calculator/CalculatorService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/launcher/TwoXLauncher.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/launcher/TwoXLauncher.java?rev=882529&r1=882528&r2=882529&view=diff
==============================================================================
--- 
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/launcher/TwoXLauncher.java
 (original)
+++ 
tuscany/sandbox/slaws/runtimecompat/2xlauncher/src/main/java/launcher/TwoXLauncher.java
 Fri Nov 20 12:10:03 2009
@@ -23,15 +23,32 @@
 import org.apache.tuscany.sca.node.Node;
 import org.apache.tuscany.sca.node.NodeFactory;
 
+import calculator.CalculatorService;
+
 
 public class TwoXLauncher {
 
     public static void main(String[] args) throws Exception {
+       TwoXLauncher.launchNode();
+    }
+    
+    public static void launchNode(){
         Node node = 
NodeFactory.newInstance().createNode("Calculator.composite", 
                 new Contribution("calculator", "../2xcalculator.jar"));
 
+        System.out.println("2.x Node created");
+
         node.start();
-       
+        
+        System.out.println("2.x Node started");
+        
+        CalculatorService calculatorService = 
node.getService(CalculatorService.class, "CalculatorServiceComponent");
+        
+        // Calculate
+        System.out.println("3 + 2=" + calculatorService.add(3, 2));
+        System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+        System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+        System.out.println("3 / 2=" + calculatorService.divide(3, 2));
         
         node.stop();
     }

Modified: 
tuscany/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java?rev=882529&r1=882528&r2=882529&view=diff
==============================================================================
--- 
tuscany/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java
 (original)
+++ 
tuscany/sandbox/slaws/runtimecompat/combinedlauncher/src/main/java/launcher/CombinedLauncher.java
 Fri Nov 20 12:10:03 2009
@@ -33,13 +33,8 @@
 
 public class CombinedLauncher {
        
-       private static final String TWO_X_NODE_LAUNCHER_EQUINOX_BUNDLE = 
"org.apache.tuscany.sca.node.launcher.equinox";
-       private static final String TWO_X_NODE_LAUNCHER_UTIL = 
"org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil";
-       private static final String TWO_X_CONTRIBUTION = 
"org.apache.tuscany.sca.node.equinox.launcher.Contribution";
-       
-       private static final String TWO_X_NODE_API_BUNDLE = 
"org.apache.tuscany.sca.node.api";
-       private static final String TWO_X_NODE = 
"org.apache.tuscany.sca.node.Node";
        
+       private static final String TWO_X_LAUNCHER = "launcher.TwoXLauncher";
        private static final String ONE_X_LAUNCHER = "launcher.OneXLauncher";
 
     public static void main(String[] args) throws Exception {
@@ -55,89 +50,35 @@
                                   
"../../../java-2.x/distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT-dir/tuscany-sca-2.0-SNAPSHOT");
         
         // To get to the console run with -Dosgi.console=<port>
+        // If running in Eclipse specifying just -Dosgi.console will bring up 
osgi> in the eclipse console
        EquinoxHost equinoxHost = new EquinoxHost();
         BundleContext bundleContext = equinoxHost.start();
         
-        // need to add in the 1.x bundle(s) also
-        Bundle oneXbundle = equinoxHost.installBundle(new 
URL("file:///C:/simon/tuscany/sandbox/runtimecompat/1xbundle/target/1.x-osgi-bundle-1.6-SNAPSHOT.jar"),
 "1xbundle");
-        Bundle oneXLauncherbundle = equinoxHost.installBundle(new 
URL("file:///C:/simon/tuscany/sandbox/runtimecompat/1xlauncher/target/1x-launcher.jar"),
 "1xlauncherbundle");
+        // the 2.x equinoz host will have added all the Tuscany 2x bundles to 
the OSGi 
+        // environment. Now add the 2.x launcher bundle
+        Bundle twoXLauncherbundle = equinoxHost.installBundle(new 
URL("file:///C:/simon/tuscany/sandbox/runtimecompat/2xlauncher/target/2x-launcher-1.0-SNAPSHOT.jar"),
 "2xlauncherbundle");
         
+        // add in the 1.x bundles also
+        Bundle oneXbundle = equinoxHost.installBundle(new 
URL("file:///C:/simon/tuscany/sandbox/runtimecompat/1xbundle/target/1.x-osgi-bundle-1.6-SNAPSHOT.jar"),
 "1xbundle");
+        Bundle oneXLauncherbundle = equinoxHost.installBundle(new 
URL("file:///C:/simon/tuscany/sandbox/runtimecompat/1xlauncher/target/1x-launcher-1.0-SNAPSHOT.jar"),
 "1xlauncherbundle");
+       
         System.out.println("Bundles loaded");
         
-        // load 2xcalculator
-        // find the the 2.x node launcher util 
-        // Get the node runtime bundle.
-/*        
-        Bundle twoXbundle = null;
-        for (Bundle b : bundleContext.getBundles()) {
-            if 
(TWO_X_NODE_LAUNCHER_EQUINOX_BUNDLE.equals(b.getSymbolicName())) {
-               twoXbundle = b;
-                break;
-            }
-        }
-        if (twoXbundle == null) {
-            throw new IllegalStateException("Bundle " + 
TWO_X_NODE_LAUNCHER_EQUINOX_BUNDLE + " is not installed");
-        }
-        
-        // All this reflection not strictly needed given the current 
-        // module dependencies. Just experimenting
-        Class<?> contributionClass = twoXbundle.loadClass(TWO_X_CONTRIBUTION);
-        Constructor<?> constructor = 
contributionClass.getConstructor(String.class, String.class);
-        
-        Class<?> bootstrapClass = 
twoXbundle.loadClass(TWO_X_NODE_LAUNCHER_UTIL);
-        Class<?> contributionArrayClass = Array.newInstance(contributionClass, 
0).getClass();
-        Method nodeMethod = bootstrapClass.getMethod("node", String.class, 
String.class, String.class, contributionArrayClass, BundleContext.class);
-        
-        twoXbundle = null;
-        for (Bundle b : bundleContext.getBundles()) {
-            if (TWO_X_NODE_API_BUNDLE.equals(b.getSymbolicName())) {
-               twoXbundle = b;
-                break;
-            }
-        }
-        if (twoXbundle == null) {
-            throw new IllegalStateException("Bundle " + TWO_X_NODE_API_BUNDLE 
+ " is not installed");
-        }
-        
-        Class<?> nodeClass = twoXbundle.loadClass(TWO_X_NODE);
-        Method startMethod = nodeClass.getMethod("start");
-        
-        String configurationURI = null;
-        String compositeURI = null;
-        String compositeContent = null;
-        Object contribution = constructor.newInstance("calculator", 
"../2xcalculator.jar");
-        Object[] contributions = 
(Object[])Array.newInstance(contributionClass, 1);
-        contributions[0] = contribution;
-        
-        Object node = nodeMethod.invoke(null, 
-                                               configurationURI,
-                                               compositeURI,
-                                               compositeContent,
-                                               
contributionArrayClass.cast(contributions),
-                                               bundleContext);
-        
-        startMethod.invoke(node);
-        
-        System.out.println("2.x Running");
-*/
+        // find the the 2.x node launcher and get it to run the calculator app
+        Class<?> twoXLauncherClass = 
twoXLauncherbundle.loadClass(TWO_X_LAUNCHER);
+        Method twoXLaunchNodeMethod = 
twoXLauncherClass.getMethod("launchNode");
+        twoXLaunchNodeMethod.invoke(null);
 
+        System.out.println("2.x run complete");
         
-       // load 1xcalculator
-        // find the the 1.x node launcher
+        // find the the 1.x node launcher and get it to run the calculator app
         Class<?> oneXLauncherClass = 
oneXLauncherbundle.loadClass(ONE_X_LAUNCHER);
-        Method launchNodeMethod = oneXLauncherClass.getMethod("launchNode");
-        launchNodeMethod.invoke(null);
-        
-        System.out.println("1.x Running");
+        Method oneXLaunchNodeMethod = 
oneXLauncherClass.getMethod("launchNode");
+        oneXLaunchNodeMethod.invoke(null);
         
-        try {
-               System.out.println("Press a key");
-               System.in.read();
-        } catch (Exception ex) {
-        }
+        System.out.println("1.x run complete");
         
         equinoxHost.stop();
     }
     
-
 }

Modified: tuscany/sandbox/slaws/runtimecompat/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/slaws/runtimecompat/pom.xml?rev=882529&r1=882528&r2=882529&view=diff
==============================================================================
--- tuscany/sandbox/slaws/runtimecompat/pom.xml (original)
+++ tuscany/sandbox/slaws/runtimecompat/pom.xml Fri Nov 20 12:10:03 2009
@@ -54,6 +54,7 @@
                 <activeByDefault>true</activeByDefault>
             </activation>
             <modules>
+                <module>1xbundle</module>
                 <module>1xlauncher</module>
                 <module>2xlauncher</module>
                 <module>combinedlauncher</module>


Reply via email to