Author: slaws
Date: Wed May 12 15:14:22 2010
New Revision: 943552

URL: http://svn.apache.org/viewvc?rev=943552&view=rev
Log:
Simple embedded JSE sample launcher. Only launches binding-ws-calculator, no 
generalized bridge etc. but using it to look at dependencies, build.xml etc.

Added:
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/   (with props)
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/pom.xml
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/
    
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/calculator/
    
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java
    
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/
    
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/
    
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/
    
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java

Propchange: tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed May 12 15:14:22 2010
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target

Added: tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/pom.xml?rev=943552&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/pom.xml (added)
+++ tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/pom.xml Wed May 12 
15:14:22 2010
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-sca</artifactId>
+        <version>2.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <artifactId>sample-launcher-embedded-jse</artifactId>
+    <name>Apache Tuscany SCA Sample Embedded Launcher JSE</name>
+
+    <repositories>
+       <repository>
+          <id>apache.incubator</id>
+          <url>http://people.apache.org/repo/m2-incubating-repository</url>
+       </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-feature-api</artifactId>
+            <type>pom</type>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-feature-core</artifactId>
+            <type>pom</type>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-feature-binding-ws</artifactId>
+            <type>pom</type>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>    
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.1</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+       <finalName>${artifactId}</finalName>
+
+       <plugins>
+         
+       </plugins>
+    </build>
+</project>

Added: 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java?rev=943552&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java
 Wed May 12 15:14:22 2010
@@ -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);
+
+}

Added: 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java?rev=943552&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
 Wed May 12 15:14:22 2010
@@ -0,0 +1,65 @@
+/*
+ * 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 launcher;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+
+/**
+ * This client program shows how to create an embedded SCA runtime, start it,
+ * and locate and invoke a SCA component 
+ */
+public class SampleJSELauncher {
+    
+    public static void main(String[] args) throws Exception {
+        SampleJSELauncher launcher = new SampleJSELauncher();
+        
+        launcher.launchBindingWSCalculator();
+    }
+    
+    public Node startNode(Contribution... contributions){
+        Node node = NodeFactory.newInstance().createNode(contributions);
+        node.start();
+        return node;
+    }
+    
+    public void stopNode(Node node){
+        node.stop();
+    }
+    
+    public void launchBindingWSCalculator(){
+        Node node = startNode(new Contribution("c1", 
"../binding-ws-calculator/target/classes"));
+        CalculatorService calculator = 
node.getService(CalculatorService.class, "CalculatorServiceComponent");
+        
+        assertEquals(calculator.add(3, 2), 5.0, 0);
+        assertEquals(calculator.subtract(3, 2), 1.0, 0);
+        assertEquals(calculator.multiply(3, 2), 6.0, 0);
+        assertEquals(calculator.divide(3, 2), 1.5, 0);
+        
+        stopNode(node);
+    }
+    
+}

Added: 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java?rev=943552&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
 (added)
+++ 
tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
 Wed May 12 15:14:22 2010
@@ -0,0 +1,34 @@
+/*
+ * 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 launcher;
+
+import org.junit.Test;
+
+
+
+/**
+ * Test the Calculator composition.
+ */
+public class LauncherTestCase {
+
+    @Test
+    public void testSample() throws Exception {
+        SampleJSELauncher.main(null);
+    }
+}


Reply via email to