summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-02-06 10:01:25 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-02-06 10:01:25 +0000
commitfd63d9f0d320bf6cace9c47b5fec7a407497a743 (patch)
tree5f1adb2d4171f148ec2756d69f63d4335319181d /sca-java-2.x/trunk
parentc99d4755650a32a9ebece84db7beb63bc867b5c6 (diff)
Update the getting started contribution to ues the contribution cretaed from the Tuscany contribution-jar Maven archetype
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1067625 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README41
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml131
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java1
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml5
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite2
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite32
-rw-r--r--sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java40
7 files changed, 138 insertions, 114 deletions
diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README
index ed0f1d0ce4..34c4b3a788 100644
--- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README
+++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/README
@@ -1,7 +1,36 @@
-The README in the <distribution-unpack-dir>/samples directory provides
-general instructions about building and running samples. (where
-distribution-unpack-dir is the directory in which you unpacked the tuscany
-binary distribution archive). Take a look there first (noting at you read it that this sample
-is not a new style sample).
+Tuscany - Getting Started - Helloworld Sample
+---------------------------------------------
+
+This sample demonstrates a simple helloworld style SCA application and how to run that with Tuscany.
+
+See the README in the top-level samples folder for general information on the Tuscany samples.
+
+This project creates a jar format SCA contribution which has a deployable SCA composite. The composite
+defines a single component named "HelloworldComponent" which implements a Helloworld service which
+is implemented by a Java class. A JUnit testcase tests running the composite and invoking the service.
+
+You can use the contribution built in the Tuscany Shell - at the root of a Tuscany binary distribution
+run the following command:
+
+ bin\tuscany.bat samples\getting-started\helloworld-contribution
+
+You may then call the helloworld service with the shell command:
+
+ invoke HelloworldComponent sayHello "your name"
+
+
+---
+
+This sample was created by the Tuscany contribution-jar Maven archetype. You can use that archetype to
+create you own SCA contribution projects by running the following maven command:
+
+ mvn archetype:generate -DarchetypeCatalog=http://tuscany.apache.org
+
+at the prompt select 1 to choose the contribution-jar archetype and then answer the questions. This project
+used the following answers:
+
+ Define value for property 'groupId': : org.apache.tuscany.sca.samples
+ Define value for property 'artifactId': : helloworld-contribution
+ Define value for property 'version': 1.0-SNAPSHOT: 2.0-SNAPSHOT
+ Define value for property 'package': org.apache.tuscany.sca.samples: sample
-TODO - finish this \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml
index d0f522d96b..5ecc7a8831 100644
--- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml
+++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/pom.xml
@@ -1,57 +1,86 @@
<?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.
+ * 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-samples</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <packaging>jar</packaging>
- <artifactId>sample-helloworld-contribution</artifactId>
- <name>Apache Tuscany SCA Samples - Getting Started - helloworld-contribution</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-base-runtime</artifactId>
- <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>${project.artifactId}</finalName>
- <plugins>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.tuscany.sca.samples</groupId>
+ <artifactId>helloworld-contribution</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>helloworld-contribution</name>
+
+ <properties>
+ <tuscany.version>2.0-SNAPSHOT</tuscany.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime</artifactId>
+ <version>${tuscany.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>helloworld-contribution</finalName>
+
+ <plugins>
<plugin>
- <groupId>org.apache.tuscany.maven.plugins</groupId>
- <artifactId>maven-tuscany-plugin</artifactId>
- <version>2.0-SNAPSHOT</version>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>${tuscany.version}</version>
</plugin>
- </plugins>
- </build>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <optimise>true</optimise>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
</project>
diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java
index aa563cbdf3..3b86c10df0 100644
--- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java
+++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/java/sample/HelloworldImpl.java
@@ -26,7 +26,6 @@ import org.oasisopen.sca.annotation.EagerInit;
public class HelloworldImpl implements Helloworld {
public String sayHello(String name) {
- System.out.println("HelloworldImpl.sayHello " + name);
return "Hello " + name;
}
diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml
index 61053aa92e..95c32fb5bf 100644
--- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml
+++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/META-INF/sca-contribution.xml
@@ -19,8 +19,7 @@
-->
<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:sample="http://sample">
-
- <deployable composite="sample:helloworld"/>
- <deployable composite="sample:helloworldws"/>
+
+ <deployable composite="sample:helloworld-contribution" />
</contribution>
diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite
index 324395c246..e0206cd6e8 100644
--- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite
+++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworld.composite
@@ -20,7 +20,7 @@
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://sample"
- name="helloworld">
+ name="helloworld-contribution">
<component name="HelloworldComponent">
<implementation.java class="sample.HelloworldImpl"/>
diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite
deleted file mode 100644
index abefee7360..0000000000
--- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/main/resources/helloworldws.composite
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://sample"
- name="helloworldws">
-
- <component name="HelloworldWSComponent">
- <implementation.java class="sample.HelloworldImpl"/>
- <service name="Helloworld">
- <binding.ws />
- </service>
- </component>
-
-</composite>
diff --git a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java
index ded7418469..be27aa68ef 100644
--- a/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java
+++ b/sca-java-2.x/trunk/samples/getting-started/helloworld-contribution/src/test/java/sample/HelloworldTestCase.java
@@ -18,31 +18,31 @@
*/
package sample;
-import static org.junit.Assert.assertEquals;
+import org.junit.Assert;
-import org.apache.tuscany.sca.node.Contribution;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
import org.junit.Test;
+import org.oasisopen.sca.NoSuchServiceException;
public class HelloworldTestCase {
@Test
- public void testSayHello() {
- // Start up the Tuscany runtime with this modules as the contribution
- Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "target/classes"));
- node.start();
-
- // This contribution is configured to deploy the helloworld.composite file
- // automatically. This defines the HelloworldComponent. Get a local proxy to it
- // and call the sayHello service operation.
- Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
- String response = helloworld.sayHello("Petra");
- System.out.println("Response from helloworld.sayHello(\"Petra\") = " + response);
- assertEquals("Hello Petra", response);
-
- // Stop the Tuscany runtime
- node.stop();
- }
+ public void testSayHello() throws NoSuchServiceException {
+ // Run the SCA composite in a Tuscany runtime
+ Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes");
+ try {
+
+ // Get the Helloworld service proxy
+ Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
+
+ // test that it works as expected
+ Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia"));
+
+ } finally {
+ // Stop the Tuscany runtime Node
+ node.stop();
+ }
+ }
}