diff options
Diffstat (limited to 'branches/sca-java-1.2.1/samples/callback-ws-service')
12 files changed, 863 insertions, 0 deletions
diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/README b/branches/sca-java-1.2.1/samples/callback-ws-service/README new file mode 100644 index 0000000000..cc7454083e --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/README @@ -0,0 +1,227 @@ +Callback Web Services Service Sample +=================================== +This sample demonstrates an SCA service with callback to a remote client +using Web service bindings for the service and the callback. + +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;target\sample-callback-ws-service.jar myserver.CallbackServer + +and on *nix do: + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-callback-ws-service.jar myserver.CallbackServer + +Now the server is started you can use the callback-ws-client sample to +exercise it. + +Sample Overview +--------------- +The sample has a single component that provides a service that is +invoked from a remote client over Web services and makes an SCA callback +over Web services to the same remote client. + +callback-ws-service/ + src/ + main/ + java/ + myserver/ + MyService.java - interface description for + MyServiceComponent + MyServiceCallback.java - interface description for callback + NyServiceImpl.java - component implementation + CallbackServer.java - starts the SCA runtime and + deploys the callbackws.composite + and then waits for the service + to be called via Web services + resources/ + callbackws.composite - the SCA assembly for this sample + test/ + java/ + myserver/ + CallbackServerTestCase.java - JUnit test case + callback-ws-service.png - a 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 with +the following commands: + +cd callback-ws-service +ant compile +ant run + +You should see the following output from the run target: + +run: + [java] 15-Jan-2008 10:21:14 org.apache.tuscany.sca.node.impl.SCADomainProxy +Impl init + [java] INFO: Domain will be started stand-alone as domain URL is not provid +ed + [java] 15-Jan-2008 10:21:14 org.apache.tuscany.sca.domain.impl.SCADomainImp +l registerNode + [java] INFO: Registered node: http://L3AW203:1331 at endpoint http://L3AW20 +3:1331 + [java] 15-Jan-2008 10:21:14 org.apache.tuscany.sca.node.impl.SCADomainProxy +Impl createRuntime + [java] INFO: Domain management configured from file:/C:/simon/tuscany/relea +se/sca-r1.1-rc2/tuscany-sca-1.1-incubating-SNAPSHOT/lib/tuscany-sca-all-1.1-incu +bating-SNAPSHOT.jar + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCADomainEventServi +ceProxyComponent + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCADomainAPIService +ProxyComponent + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCANodeManagerCompo +nent/SCANodeManagerService + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCANodeManagerCompo +nent/ComponentManagerService/* + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCANodeManagerCompo +nent/ComponentManagerService + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCADomain/scaDomain +.js + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.node.impl.SCANodeImpl ac +tivateComposite + [java] INFO: Building composite: {http://callbackws}callbackws + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.node.impl.SCANodeImpl st +artComposite + [java] INFO: Starting composite: {http://callbackws}callbackws + [java] 15-Jan-2008 10:21:26 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] Callback server started (press enter to shutdown) + +As this point the SCA service is exposed as a Web service by a Web server +started automatically by the SCA runtime. To stop the server, press enter. + +To exercise the service, run the callback-ws-client sample. Take a look at +the README in that sample and you will see you need the following commands: + +cd callback-ws-client +ant run + +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. When using Maven you don't need to run the +callback-ws-client sample as the Maven build uses a simple ping test to +make sure that the service is available. + +cd callback-ws-service +mvn + +You should see the following output from the test phase: + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running myserver.CallbackServerTestCase +15-Jan-2008 10:29:36 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl init +INFO: Domain will be started stand-alone as domain URL is not provided +15-Jan-2008 10:29:36 org.apache.tuscany.sca.domain.impl.SCADomainImpl registerNo +de +INFO: Registered node: http://L3AW203:1365 at endpoint http://L3AW203:1365 +15-Jan-2008 10:29:36 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl createR +untime +INFO: Domain management configured from file:/C:/Documents%20and%20Settings/slaw +s/.m2/repository/org/apache/tuscany/sca/tuscany-node-impl/1.1-incubating-SNAPSHO +T/tuscany-node-impl-1.1-incubating-SNAPSHOT.jar +15-Jan-2008 10:29:42 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:29:42 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +15-Jan-2008 10:29:42 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-1365 +15-Jan-2008 10:29:42 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-1365 +15-Jan-2008 10:29:42 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCADomainEventServiceProxyCompo +nent +15-Jan-2008 10:29:42 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCADomainAPIServiceProxyCompone +nt +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCANodeManagerComponent/SCANode +ManagerService +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCANodeManagerComponent/Compone +ntManagerService/* +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCANodeManagerComponent/Compone +ntManagerService +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCADomain/scaDomain.js +15-Jan-2008 10:29:43 org.apache.tuscany.sca.node.impl.SCANodeImpl activateCompos +ite +INFO: Building composite: {http://callbackws}callbackws +15-Jan-2008 10:29:43 org.apache.tuscany.sca.node.impl.SCANodeImpl startComposite + +INFO: Starting composite: {http://callbackws}callbackws +15-Jan-2008 10:29:43 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:29:43 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:29:43 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:29:43 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8086/MyServiceComponent +15-Jan-2008 10:29:43 org.apache.tuscany.sca.node.impl.SCANodeImpl stopComposite +INFO: Stopping composite: {http://callbackws}callbackws +15-Jan-2008 10:29:43 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:29:43 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-1365 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.422 sec + +This shows that the Junit test cases have run successfully. diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/build.xml b/branches/sca-java-1.2.1/samples/callback-ws-service/build.xml new file mode 100644 index 0000000000..ffbaf16f06 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/build.xml @@ -0,0 +1,73 @@ +<!-- + * 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="callback-ws-service" default="compile"> + <property name="test.class" value="myserver.CallbackServer" /> + <property name="test.jar" value="sample-callback-ws-service.jar" /> + <property name="manifest.jar" value="../../lib/tuscany-sca-manifest.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="${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="${manifest.jar}"/> + </classpath> + </java> + </target> + + <target name="run"> + <java classname="${test.class}" + fork="true"> + <classpath> + <pathelement path="target/${test.jar}"/> + <pathelement location="${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.2.1/samples/callback-ws-service/callback-ws-service.png b/branches/sca-java-1.2.1/samples/callback-ws-service/callback-ws-service.png Binary files differnew file mode 100644 index 0000000000..772ac38431 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/callback-ws-service.png diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/callback-ws-service.svg b/branches/sca-java-1.2.1/samples/callback-ws-service/callback-ws-service.svg new file mode 100644 index 0000000000..ff0a1d307b --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/callback-ws-service.svg @@ -0,0 +1,200 @@ +<?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.45.1" + sodipodi:docbase="C:\simon\tuscany\java-panic\sca\samples\callback-ws-service" + sodipodi:docname="callback-ws-service.svg" + version="1.0" + inkscape:export-filename="C:\simon\tuscany\java-panic\sca\samples\callback-ws-service\callback-ws-service.png" + inkscape:export-xdpi="52.84" + inkscape:export-ydpi="52.84" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <defs + id="defs4"> + <marker + inkscape:stockid="Arrow1Lstart" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Lstart" + style="overflow:visible"> + <path + id="path3156" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" + transform="scale(0.8) translate(12.5,0)" /> + </marker> + <marker + inkscape:stockid="Arrow1Lend" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Lend" + style="overflow:visible;"> + <path + id="path3159" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" + transform="scale(0.8) rotate(180) translate(12.5,0)" /> + </marker> + </defs> + <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="541.4664" + inkscape:cy="414.63224" + inkscape:document-units="px" + inkscape:current-layer="layer1" + inkscape:window-width="1054" + inkscape:window-height="721" + inkscape:window-x="388" + inkscape:window-y="200" /> + <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(0.991389,0,0,1,2.215655,0)"> + <rect + rx="13.79423" + ry="12.692303" + y="192.00233" + x="258.3114" + height="299.99988" + width="446.72086" + id="rect2067" + style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:2.00866628;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <flowRoot + id="flowRoot2954" + xml:space="preserve"><flowRegion + id="flowRegion2956"><rect + y="212.66591" + x="281.42856" + height="61.42857" + width="170" + id="rect2958" /></flowRegion><flowPara + id="flowPara2960">callbackws</flowPara></flowRoot> </g> + <rect + style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.1793592;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect2988" + width="115.48311" + height="102.11218" + x="432.14886" + y="307.25729" + rx="6.9853158" + ry="8.4710283" /> + <flowRoot + xml:space="preserve" + id="flowRoot2966" + transform="translate(176.75411,112.37196)"><flowRegion + id="flowRegion2968"><rect + id="rect2970" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara1883">MyService</flowPara><flowPara + id="flowPara1885">Component</flowPara></flowRoot> <path + style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.34265757px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 372.72286,323.25736 L 441.18554,323.25736 L 453.63329,358.34829 L 439.11093,390.73995 L 372.72286,390.73995 L 388.28257,358.34829 L 372.72286,323.25736 z " + id="path3017" /> + <flowRoot + xml:space="preserve" + id="flowRoot1889" + transform="translate(-56.05091,109.83236)" + style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion + id="flowRegion1891"><rect + id="rect1893" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" + style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara + id="flowPara1897">http://localhost:8086/MyServiceComponent</flowPara><flowPara + id="flowPara1899" /></flowRoot> <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.1331737px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1" + d="M 231.49516,358.3136 C 387.07627,357.7325 387.07627,357.7325 387.07627,357.7325" + id="path1901" /> + <path + style="fill:#b74aae;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.25983226px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 438.85378,352.31178 L 397.27706,352.31178 L 389.71767,369.02293 L 398.53696,384.44862 L 438.85378,384.44862 L 429.40452,369.02293 L 438.85378,352.31178 z " + id="path3361" /> + <flowRoot + xml:space="preserve" + id="flowRoot3363" + transform="translate(106.89573,117.99181)" + style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion + id="flowRegion3365"><rect + id="rect3367" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" + style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara + id="flowPara3371">myservice</flowPara></flowRoot> <flowRoot + xml:space="preserve" + id="flowRoot3375" + transform="translate(111.18143,149.42038)" + style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion + id="flowRegion3377"><rect + id="rect3379" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" + style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara + id="flowPara3383">callback</flowPara></flowRoot> <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.14703035;stroke-linecap:butt;stroke-linejoin:miter;marker-start:url(#Arrow1Lstart);marker-end:none;stroke-miterlimit:4;stroke-dasharray:6.88218229, 1.14703038;stroke-dashoffset:0;stroke-opacity:1" + d="M 232.21637,370.32429 C 392.06934,369.7448 392.06934,369.7448 392.06934,369.7448" + id="path3387" /> + </g> +</svg> diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/pom.xml b/branches/sca-java-1.2.1/samples/callback-ws-service/pom.xml new file mode 100644 index 0000000000..372998e494 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/pom.xml @@ -0,0 +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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>1.2.1-incubating-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + <artifactId>sample-callback-ws-service</artifactId> + <name>Apache Tuscany SCA Callback Web Service Sample</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-node-api</artifactId> + <version>1.2.1-incubating-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.2.1-incubating-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>1.2.1-incubating-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-tomcat</artifactId> + <version>1.2.1-incubating-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-impl</artifactId> + <version>1.2.1-incubating-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.2.1/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java new file mode 100644 index 0000000000..d4abc2f597 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java @@ -0,0 +1,47 @@ +/* + * 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 myserver; + +import java.io.IOException; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + * This server program shows how to create and start an SCA runtime that + * activates the MyService Web service endpoint. + */ +public class CallbackServer { + + public static void main(String[] args) throws Exception { + + SCANode node = SCANodeFactory.createNodeWithComposite("callbackws.composite"); + + try { + System.out.println("Callback server started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + node.destroy(); + System.out.println("Callback server stopped"); + } + +} diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyService.java b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyService.java new file mode 100644 index 0000000000..7c1c14f574 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyService.java @@ -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 myserver; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * The remote service that will be invoked by the client + */ +@Remotable +@Callback(MyServiceCallback.class) +public interface MyService { + + @OneWay + void someMethod(String arg); +} diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java new file mode 100644 index 0000000000..532d1b0497 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java @@ -0,0 +1,30 @@ +/* + * 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 myserver; + +import org.osoa.sca.annotations.Remotable; + +/** + * The callback interface for {@link MyService}. + */ +@Remotable +public interface MyServiceCallback { + + void receiveResult(String result); +} diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java new file mode 100644 index 0000000000..f36ea43a97 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java @@ -0,0 +1,56 @@ +/* + * 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 myserver; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * This class implements MyService and uses a callback. + */ +@Service(MyService.class) +@Scope("COMPOSITE") +public class MyServiceImpl implements MyService { + + private MyServiceCallback myServiceCallback; + + /** + * The setter used by the runtime to set the callback reference + * @param myServiceCallback + */ + @Callback + public void setMyServiceCallback(MyServiceCallback myServiceCallback) { + System.out.println("setMyServiceCallback on thread " + Thread.currentThread()); + this.myServiceCallback = myServiceCallback; + } + + public void someMethod(String arg) { + System.out.println("someMethod on thread " + Thread.currentThread()); + // invoke the callback + try { + System.out.println("Sleeping ..."); + Thread.sleep(2000); + myServiceCallback.receiveResult(arg + " -> receiveResult "); + } catch(Exception e) { + System.out.println("RuntimeException invoking receiveResult: " + e.toString()); + e.printStackTrace(); + } + } +} diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..7c0f6d9315 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ +<?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. +--> +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://callbackws" + xmlns:cbws="http://callbackws"> + <deployable composite="cbws:callbackws" /> +</contribution> diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/resources/callbackws.composite b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/resources/callbackws.composite new file mode 100644 index 0000000000..4cfadccfd3 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/src/main/resources/callbackws.composite @@ -0,0 +1,35 @@ +<?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://callbackws"
+ name="callbackws">
+
+ <component name="MyServiceComponent">
+ <implementation.java class="myserver.MyServiceImpl" /> + <service name="MyService">
+ <interface.java interface="myserver.MyService"
+ callbackInterface="myserver.MyServiceCallback" />
+ <binding.ws uri="http://localhost:8086/MyServiceComponent" />
+ <callback>
+ <binding.ws />
+ </callback>
+ </service>
+ </component>
+</composite>
\ No newline at end of file diff --git a/branches/sca-java-1.2.1/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java b/branches/sca-java-1.2.1/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java new file mode 100644 index 0000000000..57ea5b0229 --- /dev/null +++ b/branches/sca-java-1.2.1/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.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 myserver; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests that the callback server is available + */ +public class CallbackServerTestCase { + + private SCANode node; + + @Before + public void startServer() throws Exception { + node = SCANodeFactory.createNodeWithComposite("callbackws.composite"); + } + + @Test + public void testPing() throws IOException { + new Socket("127.0.0.1", 8086); + } + + @After + public void stopServer() throws Exception { + node.destroy(); + } +} |