summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.3.1/samples/binding-echo
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-11 07:29:53 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-11 07:29:53 +0000
commit23297fa3b1f66d74325c8352cb8f5aae599a3090 (patch)
tree2c3017479edf2ae3f45e656975db5a53eed71b10 /branches/sca-java-1.3.1/samples/binding-echo
parentc5ab90dd4248519034478db64a9c32a0c3f91f3a (diff)
Start branch for 1.3.1, the only changes in this commit are for the version
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@684661 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3.1/samples/binding-echo')
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/README104
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/binding-echo.pngbin0 -> 7846 bytes
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/binding-echo.svg174
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/build.xml75
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/pom.xml71
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/Echo.java29
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/EchoBindingClient.java51
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java44
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/src/main/resources/EchoBinding.composite40
-rw-r--r--branches/sca-java-1.3.1/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java57
10 files changed, 645 insertions, 0 deletions
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/README b/branches/sca-java-1.3.1/samples/binding-echo/README
new file mode 100644
index 0000000000..2772460cc6
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/README
@@ -0,0 +1,104 @@
+Binding Echo Sample Application
+===============================
+This sample demonstrates how to use the new binding extension
+binding-echo-extension.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+If you just want to run it to see what happens, open a command prompt,
+navigate to this sample directory, and do
+
+ant run
+
+OR if you don't have ant, on Windows do
+
+java -cp ..\..\lib\tuscany-sca-manifest.jar;..\binding-echo-extension\target\sample-binding-echo-extension.jar;target\sample-binding-echo.jar echo.EchoBindingClient
+
+and on *nix do
+
+java -cp ../../lib/tuscany-sca-manifest.jar:../binding-echo-extension/target/sample-binding-echo-extension.jar:target/sample-binding-echo.jar echo.EchoBindingClient
+
+This looks like a long command. The three things we add to the classpath are
+
+tuscany-sca-manifest.jar - all of the standard Tuscany SCA runtime and
+ extension classes
+sample-binding-echo-extension.jar - the new echo binding extension implementation
+sample-binding-echo - the application that uses the echo binding
+
+Note: this sample currently is not working on Linux
+
+Sample Overview
+---------------
+This sample contains an application (client and server code) that uses
+an SCA binding that simply echoes back any messages that are sent to it.
+
+binding-echo/
+ src/
+ main/
+ java/
+ echo/
+ Echo.java - interface definition for the sample
+ reference and service
+ EchoComponentImpl.java - sample component implementation with
+ echo binding reference
+ EchoBindingClient.java - sample client
+ resources/
+ EchoBinding.composite - the SCA assembly for this sample
+ test/
+ java/
+ echo
+ EchoBindingTestCase.java - sample JUnit test case for the sample
+ client
+ binding-echo.png - pictorial representation of the sample
+ .composite file
+ build.xml - the Ant build file
+ pom.xml - the Maven build file
+
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+With the binary distribution the sample can be built and run using Ant as
+follows.
+
+cd binding-echo
+ant compile
+ant run
+
+You should see the following output from the run target.
+
+run:
+ [java] Passing thro invoker...
+ [java] Returned message: foo
+ [java] Echo reference = foo
+ [java] Passing thro invoker...
+ [java] Returned message: bar
+ [java] Echo service = bar
+
+
+Building And Running The Sample Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built and
+run using Maven as follows.
+
+cd binding-echo
+mvn
+
+You should see the following output from the test phase.
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running echo.EchoBindingTestCase
+Passing thro invoker...
+Returned message: foo
+Passing thro invoker...
+Returned message: bar
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.811 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
+This shows that the Junit test cases have run successfully.
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/binding-echo.png b/branches/sca-java-1.3.1/samples/binding-echo/binding-echo.png
new file mode 100644
index 0000000000..a38d985363
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/binding-echo.png
Binary files differ
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/binding-echo.svg b/branches/sca-java-1.3.1/samples/binding-echo/binding-echo.svg
new file mode 100644
index 0000000000..5b5051bef5
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/binding-echo.svg
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ * 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.
+-->
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="1052.3622"
+ height="744.09448"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.44"
+ sodipodi:docbase="C:\simon\Projects\Tuscany\java\java-head\sca\samples\binding-echo"
+ sodipodi:docname="binding-echo.svg"
+ version="1.0"
+ inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\binding-echo\binding-echo.png"
+ inkscape:export-xdpi="52.84"
+ inkscape:export-ydpi="52.84">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.4"
+ inkscape:cx="528.85714"
+ inkscape:cy="406.01174"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:window-width="1142"
+ inkscape:window-height="722"
+ inkscape:window-x="58"
+ inkscape:window-y="135" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <g
+ id="g2997"
+ transform="matrix(1.038749,0,0,1.009461,-29.25616,-1.807024)">
+ <rect
+ rx="8.7034655"
+ ry="12.692303"
+ y="192.00233"
+ x="375.89822"
+ height="299.99988"
+ width="281.85843"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:1.95312572;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <flowRoot
+ id="flowRoot2954"
+ xml:space="preserve"
+ transform="translate(104.5213,-10.61387)"><flowRegion
+ id="flowRegion2956"><rect
+ y="212.66591"
+ x="281.42856"
+ height="61.42857"
+ width="170"
+ id="rect2958" /></flowRegion><flowPara
+ id="flowPara2960">EchoBinding</flowPara></flowRoot> <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 397.85714,346.95163 L 440,346.95163"
+ id="path1896"
+ transform="matrix(0.962696,0,0,0.990628,28.1648,1.790088)" />
+ </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="85.862968"
+ x="450.63062"
+ y="302.8819"
+ rx="6.9961648"
+ ry="7.1230249" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(183.0398,96.94336)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">EchoComponent</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 433.4801,334.72889 L 466.81514,334.72889 L 472.87605,347.86087 L 465.80499,359.98271 L 433.4801,359.98271 L 441.05625,347.86087 L 433.4801,334.72889 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 546.73254,332.89061 L 580.06758,332.89061 L 586.12849,346.02259 L 579.05743,358.14443 L 546.73254,358.14443 L 554.30869,346.02259 L 546.73254,332.89061 z "
+ id="path3019" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1.00000012px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 328.15933,319.32471 L 387.4834,319.32471 L 398.26959,346.57097 L 385.68571,371.72138 L 328.15933,371.72138 L 341.64208,346.57097 L 328.15933,319.32471 z "
+ id="path1883" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 610.30199,319.1819 L 674.46121,319.1819 L 686.12651,346.05674 L 672.517,370.8643 L 610.30199,370.8643 L 624.88364,346.05674 L 610.30199,319.1819 z "
+ id="path1885" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1887"
+ transform="translate(62.97619,122.4038)"><flowRegion
+ id="flowRegion1889"><rect
+ id="rect1891"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1893"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:12;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%">Echo</flowPara><flowPara
+ id="flowPara1895"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:12;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%">Serivce</flowPara></flowRoot> <text
+ xml:space="preserve"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Arial"
+ x="625.14288"
+ y="343.23737"
+ id="text1897"
+ sodipodi:linespacing="100%"><tspan
+ sodipodi:role="line"
+ id="tspan1899"
+ x="625.14288"
+ y="343.23737"
+ style="font-family:Arial;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:12;text-anchor:start;text-align:start;writing-mode:lr;line-height:100%">Echo</tspan><tspan
+ sodipodi:role="line"
+ x="625.14288"
+ y="355.23737"
+ id="tspan1901"
+ style="font-family:Arial;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:12;text-anchor:start;text-align:start;writing-mode:lr;line-height:100%">Reference</tspan></text>
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 585.71429,345.52305 C 624.28571,345.52305 624.28571,345.52305 624.28571,345.52305"
+ id="path1898" />
+ </g>
+</svg>
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/build.xml b/branches/sca-java-1.3.1/samples/binding-echo/build.xml
new file mode 100644
index 0000000000..7689ef3a54
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/build.xml
@@ -0,0 +1,75 @@
+<!--
+ * 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 name="binding-echo" default="compile">
+ <property name="test.class" value="echo.EchoBindingClient" />
+ <property name="test.jar" value="sample-binding-echo.jar" />
+
+ <target name="init">
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5">
+ <classpath>
+ <pathelement location="../binding-echo-extension/target/sample-binding-echo-extension.jar"/>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${test.jar}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${test.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run-classes">
+ <java classname="${test.class}"
+ fork="true">
+ <classpath>
+ <pathelement path="target/classes"/>
+ <pathelement location="../binding-echo-extension/target/sample-binding-echo-extension.jar"/>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run">
+ <java classname="${test.class}"
+ fork="true">
+ <classpath>
+ <pathelement location="target/${test.jar}"/>
+ <pathelement location="../binding-echo-extension/target/sample-binding-echo-extension.jar"/>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="clean">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+</project>
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/pom.xml b/branches/sca-java-1.3.1/samples/binding-echo/pom.xml
new file mode 100644
index 0000000000..04edd521cc
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/pom.xml
@@ -0,0 +1,71 @@
+<?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>1.3.1-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-binding-echo</artifactId>
+ <name>Apache Tuscany SCA Echo Binding Sample Application</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-host-embedded</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sample-binding-echo-extension</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/Echo.java b/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/Echo.java
new file mode 100644
index 0000000000..1d5e973f33
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/Echo.java
@@ -0,0 +1,29 @@
+/*
+ * 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 echo;
+
+/**
+ * Interface of our sample Echo service.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Echo {
+
+ String echo(String msg);
+}
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/EchoBindingClient.java b/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/EchoBindingClient.java
new file mode 100644
index 0000000000..21bdff4011
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/EchoBindingClient.java
@@ -0,0 +1,51 @@
+/*
+ * 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 echo;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import echo.server.EchoServer;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingClient {
+
+ public static void main(String[] args) throws Exception {
+
+ SCADomain scaDomain = SCADomain.newInstance("EchoBinding.composite");
+
+ // Call the echo service component which will, in turn, call a reference
+ // with an echo binding. The echo binding will echo the given string.
+ Echo service = scaDomain.getService(Echo.class, "EchoComponent");
+ String echoString = service.echo("foo");
+ System.out.println("Echo reference = " + echoString );
+
+ // Call the echo server. This will dispatch the call to a service with an
+ // echo binding. The echo binding will pass the call to the echo component.
+ echoString = EchoServer.getServer().sendReceive("http://tempuri.org", "bar");
+ System.out.println("Echo service = " + echoString );
+
+ scaDomain.close();
+
+ }
+
+}
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java b/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java
new file mode 100644
index 0000000000..ba68dfe908
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java
@@ -0,0 +1,44 @@
+/*
+ * 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 echo;
+
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * A simple client component that uses a reference with an Echo binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoComponentImpl implements Echo {
+
+ private Echo echoReference;
+
+ @Constructor
+ public EchoComponentImpl(@Reference(name = "echoReference", required = true) Echo echoReference) {
+ this.echoReference = echoReference;
+ }
+
+ public String echo(String msg) {
+ String result = echoReference.echo(msg);
+ System.out.println("Returned message: "+ result);
+ return result;
+ }
+}
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/src/main/resources/EchoBinding.composite b/branches/sca-java-1.3.1/samples/binding-echo/src/main/resources/EchoBinding.composite
new file mode 100644
index 0000000000..94612fb325
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/src/main/resources/EchoBinding.composite
@@ -0,0 +1,40 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample/echo"
+ xmlns:se="http://sample/echo"
+ xmlns:e="http://echo"
+ name="EchoBinding">
+
+ <service name="EchoService" promote="EchoComponent">
+ <interface.java interface="echo.Echo"/>
+ <e:binding.echo uri="http://tempuri.org" />
+ </service>
+
+ <component name="EchoComponent">
+ <implementation.java class="echo.EchoComponentImpl"/>
+ </component>
+
+ <reference name="EchoReference" promote="EchoComponent/echoReference">
+ <interface.java interface="echo.Echo"/>
+ <e:binding.echo uri="http://tempuri.org" />
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-1.3.1/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java b/branches/sca-java-1.3.1/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java
new file mode 100644
index 0000000000..1a597fc80f
--- /dev/null
+++ b/branches/sca-java-1.3.1/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java
@@ -0,0 +1,57 @@
+/*
+ * 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 echo;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import echo.Echo;
+import echo.server.EchoServer;
+
+public class EchoBindingTestCase extends TestCase {
+
+ private SCADomain scaDomain;
+
+ @Override
+ protected void setUp() throws Exception {
+ scaDomain = SCADomain.newInstance("EchoBinding.composite");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ scaDomain.close();
+ }
+
+ public void testReference() throws Exception {
+ // Call the echo service component which will, in turn, call a reference
+ // with an echo binding. The echo binding will echo the given string.
+ Echo service = scaDomain.getService(Echo.class, "EchoComponent");
+ String echoString = service.echo("foo");
+ assertEquals(echoString, "foo");
+ }
+
+ public void testService() throws Exception {
+ // Call the echo server. This will dispatch the call to a service with an
+ // echo binding. The echo binding will pass the call to the echo component.
+ String echoString = EchoServer.getServer().sendReceive("http://tempuri.org", "bar");
+ assertEquals(echoString, "bar");
+ }
+}