diff options
Diffstat (limited to 'sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc')
13 files changed, 895 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/README b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/README new file mode 100644 index 0000000000..f57eb26920 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/README @@ -0,0 +1,86 @@ +Hello World JSONRPC Sample +========================== +This sample demostrates the JSONRPC binding using a simple web app that +talks JSONRPC to an SCA service. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-helloworldjsonrpc.war) +to you web application server. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-helloworldjsonrpc + +The port and hostname will of course vary depending on your local installation. + +Sample Overview +--------------- +The sample provides a single service which with an operation that reflects +a greeting back to the called. The service is exposed using the JSONRPC +binding. The web app provided shows how the service can be called either via +via the SCA provided JSON client or by using the DOJO toolkit. + +helloworl-jsonrpc/ + src/ + main/ + java/ + helloworldjsonrpc/ + HelloWorldService.java - service interface + HelloWorlsServiceImple.java - service implementation + resources/ + jsonrpc.composite - the SCA assembly for this sample + webapp + WEB-INF/ + web.xml - defines the listener that starts up the + Tuscany SCA runtime + HelloWorldJSONRPC.html - the web application that calls the + SCA service via JSONRPC + + helloworld-jsonrpc.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file that unpacks the + dojo installation + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd helloworld-jsonrpc +ant package + +This should result in a war file (sample-helloworldjsonrpc.war) in the target +directory. Copy this war file to your web app deployment directory in you +web app container. + +The process for getting the web app running will depend on which web app container +you are using. For example, if you are using Tomcat then it is simply a matter +of copying the WAR file to the webapps directory. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-helloworldjsonrpc + +The port and hostname will of course vary depending on your local installation. + +You should see a web page that allows you to send messages, via JSONRPC, to the +application running in the Tuscany SCA Runtime + +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 helloworld-jsonrpc +mvn + +Again this should result in a war file (sample-calculator-web.war) in the target +directory. Follow the steps described in the previous section for running the web +app and for the expected results. + diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/build-dojo.xml b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/build-dojo.xml new file mode 100644 index 0000000000..335a10817a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/build-dojo.xml @@ -0,0 +1,91 @@ +<?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 name="DojoZipInstaller"> + + + <property name="dojo.version" value="0.4.0"/> + <property name="dojo.distro" value="ajax"/> + <property name="unpack.location" value="${basedir}/src/main/webapp/dojo"/> + + + <target name="check-dojo-installed"> + <condition property="already.installed" > + <available file="${localRepository}/dojo/dojo-${dojo.distro}/${dojo.version}/dojo-${dojo.distro}-${dojo.version}.zip"/> + </condition> + <condition property="maven.suffix" value=""> + <os family="unix"/> + </condition> + <condition property="maven.suffix" value=".bat"> + <os family="windows"/> + </condition> + </target> + + + <target name="check-dojo-unpacked"> + <condition property="already.unpacked" > + <available file="${unpack.location}"/> + </condition> + </target> + + <target name="install-dojo" depends="check-dojo-installed" unless="already.installed"> + <mkdir dir="${basedir}/target/dojo-download/"/> + <get src="http://download.dojotoolkit.org/release-${dojo.version}/dojo-${dojo.version}-${dojo.distro}.zip" + dest="${basedir}/target/dojo-download/dojo-${dojo.version}-${dojo.distro}.zip" + verbose="true" + usetimestamp="true"/> + <exec executable="mvn${maven.suffix}" dir="${basedir}" failonerror="false"> + <arg line="install:install-file -DgroupId=dojo -DartifactId=dojo-${dojo.distro} -Dversion=${dojo.version} -Dpackaging=zip -DgeneratePom=true -Dfile=${basedir}/target/dojo-download/dojo-${dojo.version}-${dojo.distro}.zip"/> + </exec> + </target> + + <target name="install-dojo-nomaven" depends="check-dojo-installed" unless="already.installed"> + <mkdir dir="${basedir}/target/dojo-download/"/> + <get src="http://download.dojotoolkit.org/release-${dojo.version}/dojo-${dojo.version}-${dojo.distro}.zip" + dest="${basedir}/target/dojo-download/dojo-${dojo.version}-${dojo.distro}.zip" + verbose="true" + usetimestamp="true"/> + <copy file="${basedir}/target/dojo-download/dojo-${dojo.version}-${dojo.distro}.zip" + tofile="${localRepository}/dojo/dojo-${dojo.distro}/${dojo.version}/dojo-${dojo.distro}-${dojo.version}.zip"/> + </target> + + + <target name="unpack-dojo-files" depends="check-dojo-installed, check-dojo-unpacked" unless="already.unpacked"> + <fail message="dojo zip file not installed in local repository: ${localRepository}" unless="already.installed"/> + <mkdir dir="${basedir}/target/dojo-unpack-temp/"/> + <unzip src="${localRepository}/dojo/dojo-${dojo.distro}/${dojo.version}/dojo-${dojo.distro}-${dojo.version}.zip" + dest="${basedir}/target/dojo-unpack-temp/" + overwrite="false"> + <patternset> + <include name="dojo-${dojo.version}-${dojo.distro}/**"/> + <exclude name="dojo-${dojo.version}-${dojo.distro}/demos/**"/> + <exclude name="dojo-${dojo.version}-${dojo.distro}/tests/**"/> + </patternset> + </unzip> + <move file="${basedir}/target/dojo-unpack-temp/dojo-${dojo.version}-${dojo.distro}" + tofile="${unpack.location}" + verbose="true"/> + <delete dir="${basedir}/target/dojo-unpack-temp/"/> + </target> + + + <target name="clean-dojo-files"> + <delete dir="${unpack.location}"/> + </target> +</project> diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/build.xml b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/build.xml new file mode 100644 index 0000000000..e188a47e7a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/build.xml @@ -0,0 +1,106 @@ +<!-- + * 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="helloworld-jsonrpc" default="package"> + <property name="settings.localRepository" value="./target/repo" /> + <property name="artifactId" value="sample-helloworld-jsonrpc" /> + + <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="../../lib/tuscany-sca-manifest.jar"/> + </classpath> + </javac> + <copy todir="target/classes"> + <fileset dir="src/main/resources"/> + </copy> + </target> + + <target name="package" depends="compile"> + <ant antfile="./build-dojo.xml" target="install-dojo-nomaven"> + <property name="localRepository" value="${settings.localRepository}"/> + </ant> + + <ant antfile="./build-dojo.xml" target="unpack-dojo-files"> + <property name="localRepository" value="${settings.localRepository}"/> + <property name="artifactId" value="${artifactId}"/> + </ant> + + <war destfile="target/sample-helloworldjsonrpc.war" + webxml="src/main/webapp/WEB-INF/web.xml"> + <fileset dir="src/main/webapp"/> + <zipfileset dir="../../modules" prefix="WEB-INF/lib"> + <include name="sca-api-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-assembly-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-assembly-xml-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-binding-jsonrpc-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-contribution-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-contribution-impl-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-core-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-core-databinding-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-core-spi-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-databinding-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-host-embedded-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-host-http-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-host-webapp-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-runtime-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-xml-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-interface-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-runtime-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-xml-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-interface-wsdl-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-interface-wsdl-runtime-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-interface-wsdl-xml-0.90-incubating-SNAPSHOT.jar"/> + <include name="tuscany-policy-0.90-incubating-SNAPSHOT.jar"/> + </zipfileset> + <lib dir="../../lib"> + <include name="commonj-api-0.90-incubating-SNAPSHOT.jar"/> + <include name="json-rpc-1.0.jar"/> + <include name="stax-api-1.0.1.jar"/> + <include name="wsdl4j-1.6.2.jar"/> + <include name="wstx-asl-3.2.0.jar"/> + <include name="XmlSchema-1.3.1.jar"/> + <include name="**/../../modules/*.jar"/> + </lib> + <classes dir="target/classes"/> + </war> + + <ant antfile="./build-dojo.xml" target="clean-dojo-files"> + <property name="localRepository" value="${settings.localRepository}"/> + <property name="artifactId" value="${artifactId}"/> + </ant> + </target> + + + + <target name="clean"> + <delete quiet="true" includeemptydirs="true"> + <fileset dir="target"/> + </delete> + </target> +</project> diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/helloworld-jsonrpc.png b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/helloworld-jsonrpc.png Binary files differnew file mode 100644 index 0000000000..57f90aed01 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/helloworld-jsonrpc.png diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/helloworld-jsonrpc.svg b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/helloworld-jsonrpc.svg new file mode 100644 index 0000000000..fe966d8c17 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/helloworld-jsonrpc.svg @@ -0,0 +1,177 @@ +<?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\helloworld-jsonrpc" + sodipodi:docname="helloworld-jsonrpc.svg" + version="1.0" + inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\helloworld-jsonrpc\helloworld-jsonrpc.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="516.28571" + inkscape:cy="414.63224" + inkscape:document-units="px" + inkscape:current-layer="layer1" + inkscape:window-width="1054" + inkscape:window-height="721" + inkscape:window-x="158" + inkscape:window-y="164" /> + <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="translate(144.2857,52.85714)"> + <rect + rx="8.0946665" + ry="12.692303" + y="192.00233" + x="258.31134" + height="299.99988" + width="262.14267" + id="rect2067" + style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:1.99999893;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">helloworldjsonrpc</flowPara></flowRoot> </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="449.91632" + y="349.31049" + rx="6.9961648" + ry="7.1230249" /> + <flowRoot + xml:space="preserve" + id="flowRoot2966" + transform="translate(190.3256,143.3719)"><flowRegion + id="flowRegion2968"><rect + id="rect2970" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara2972">HelloWorld</flowPara><flowPara + id="flowPara1883">JSONService</flowPara><flowPara + id="flowPara1885">Component</flowPara></flowRoot> <path + style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1.00000036px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 373.48019,364.72909 L 455.16689,364.72909 L 470.019,392.34681 L 452.69154,417.84009 L 373.48019,417.84009 L 392.04536,392.34681 L 373.48019,364.72909 z " + id="path3017" /> + <flowRoot + xml:space="preserve" + id="flowRoot1887" + transform="translate(113.6483,167.4037)"><flowRegion + id="flowRegion1889"><rect + id="rect1891" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara1893">HelloWorld</flowPara><flowPara + id="flowPara1897">Service</flowPara></flowRoot> <rect + style="opacity:1;fill:#f19a9a;fill-opacity:1;stroke:#2e2424;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:3, 1;stroke-dashoffset:0;stroke-opacity:1" + id="rect1888" + width="85" + height="97.85714" + x="214.28571" + y="340.52307" + rx="6.9961648" + ry="7.1230249" /> + <flowRoot + xml:space="preserve" + id="flowRoot1892" + transform="translate(-56.88742,135.3526)"><flowRegion + id="flowRegion1894"><rect + id="rect1896" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara1900">WebApp</flowPara></flowRoot> <rect + style="opacity:1;fill:#f19a9a;fill-opacity:1;stroke:#2e2424;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:3, 1;stroke-dashoffset:0;stroke-opacity:1" + id="rect1912" + width="45.714287" + height="40.714287" + x="277.85715" + y="370.52304" + rx="6.9961648" + ry="7.1230249" /> + <flowRoot + xml:space="preserve" + id="flowRoot1914" + transform="translate(1.400116,166.6895)"><flowRegion + id="flowRegion1916"><rect + id="rect1918" + width="170" + height="61.42857" + x="281.42856" + y="212.66591" /></flowRegion><flowPara + id="flowPara1920">DOJO</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 324.28571,391.23734 C 391.42857,391.95163 391.42857,391.95163 391.42857,391.95163" + id="path1922" /> + </g> +</svg> diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/pom.xml b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/pom.xml new file mode 100644 index 0000000000..0a71c4c946 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/pom.xml @@ -0,0 +1,125 @@ +<?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>0.90-incubating-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + <artifactId>sample-helloworld-jsonrpc</artifactId> + <packaging>war</packaging> + <name>Apache Tuscany JSON-RPC Sample WebApp</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-webapp</artifactId> + <version>0.90-incubating-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>0.90-incubating-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-jsonrpc</artifactId> + <version>0.90-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>sample-helloworldjsonrpc</finalName> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <id>install-dojo</id> + <phase>validate</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <ant antfile="./build-dojo.xml" target="install-dojo"> + <property name="localRepository" value="${settings.localRepository}"/> + </ant> + </tasks> + </configuration> + </execution> + <execution> + <id>copy-dojo-files</id> + <phase>generate-resources</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <ant antfile="./build-dojo.xml" target="unpack-dojo-files"> + <property name="localRepository" value="${settings.localRepository}"/> + <property name="artifactId" value="${artifactId}"/> + </ant> + </tasks> + </configuration> + </execution> + <execution> + <id>clean-dojo-files</id> + <phase>clean</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <ant antfile="./build-dojo.xml" target="clean-dojo-files"> + <property name="localRepository" value="${settings.localRepository}"/> + <property name="artifactId" value="${artifactId}"/> + </ant> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldService.java b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldService.java new file mode 100644 index 0000000000..3d8ea24f04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldService.java @@ -0,0 +1,28 @@ +/* + * 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 helloworldjsonrpc; + +/** + * This is the business interface of the HelloWorld service component. + */ +public interface HelloWorldService { + + String getGreetings(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..35fd00fabd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java @@ -0,0 +1,36 @@ +/* + * 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 helloworldjsonrpc; + +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service component. + */ +@Service(HelloWorldService.class) +public class HelloWorldServiceImpl implements HelloWorldService { + + /* + * @see org.apache.tuscany.samples.helloworld.HelloWorldServiceComponent#getGreetings() + */ + public String getGreetings(String name) { + return "jsonrpcHello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/resources/jsonrpc.composite b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/resources/jsonrpc.composite new file mode 100644 index 0000000000..6ceef2041f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/resources/jsonrpc.composite @@ -0,0 +1,36 @@ +<?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"
+ xmlns:sample="http://sample"
+ name="helloworldjsonrpc">
+
+ <service name="HelloWorldService" promote="HelloWorldJSONServiceComponent/HelloWorldService">
+ <interface.java interface="helloworldjsonrpc.HelloWorldService"/>
+ <binding.jsonrpc/>
+ </service>
+
+ <component name="HelloWorldJSONServiceComponent">
+ <implementation.java class="helloworldjsonrpc.HelloWorldServiceImpl"/>
+ </component>
+
+</composite>
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/HelloWorldJSONRPC.html b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/HelloWorldJSONRPC.html new file mode 100644 index 0000000000..a684143794 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/HelloWorldJSONRPC.html @@ -0,0 +1,134 @@ +<html> +<!-- + * 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. + --> + <head> + <title>Tuscany JSON-RPC HelloWorld Example</TITLE> + + <script type="text/javascript"> + var djConfig = {isDebug: true,debugContainerId: "dojoDebug" }; + //djConfig.debugAtAllCosts = true; + </script> + + <script type="text/javascript" src="services/SCA/scripts"></script> + + <script language="JavaScript"> + SCA = new JSONRpcClient("services/HelloWorldService"); + + function getGreeting() { + var name = document.getElementById("name").value; + var result = SCA.HelloWorldService.getGreetings(name); + document.getElementById('greeting').innerHTML=result; + } + </script> + + <script type="text/javascript" src="dojo/dojo.js"> + </script> + + <script type="text/javascript"> + dojo.require("dojo.widget.*"); + dojo.require("dojo.widget.Button"); + dojo.require("dojo.rpc.JsonService"); + </script> + + <link rel="stylesheet" type="text/css" href="style.css" /> + </head> + + <body> + + <h2>Tuscany JSON-RPC HelloWorld Examples</h2> + + <table> + <tr> + <th colspan="2">Non-Dojo Example</th> + </tr> + <tr> + <td colspan="2"> + This example uses the JavaScript served from + <a href="services/SCA/scripts">services/SCA/scripts</a> + to make JSON-RPC requests to the service located at services/HelloWorldService. + </tr> + <tr> + <td>Request</td> + <td>Response</td> + </tr> + <tr> + <td> + <p> + Name please: + <input type="text" id="name" size="30" value="World" /> + <input type="button" value="Submit" onclick="getGreeting()" /> + </p> + + </td> + <td> + <div id='greeting'>None Yet.</div> + </td> + </tr> + </table> + + <br/> + + <table> + <tr> + <th colspan="2">Dojo Example</th> + </tr> + <tr> + <td colspan="2"> + <p>This example uses the <a href="http://dojotoolkit.org/">Dojo Toolkit</a> + to create a JavaScript object <code>helloWorldService</code> for the service at services/HelloWorldService + using <a href="http://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book9">Dojo's RPC classes</a> + and providing them with <a href="services/HelloWorldService?smd">services/HelloWorldService?smd</a> + for <a href="http://dojo.jot.com/SMD">Simple Method Description (SMD)</a> input.</p> + <p>It then creates a Dojo button that will envoke the <code>getGreetings</code> method of the <code>helloWorldService</code> object.</p> + </tr> + <tr> + <td>Request</td> + <td>Response</td> + </tr> + <tr> + <td> + <br><div id="myecho" dojoType="Button" onClick='helloWorldService.getGreetings("Dojo").addCallback(contentCallBack);'>helloWorldService.getGreetings("Dojo").addCallback(contentCallBack);</div><br> + </td> + <td> + <div id="ReturnedContent">None Yet.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div id="dojoDebug">Dojo Debug:</div> + </td> + </tr> + </table> + + + + + <script type="text/javascript"> + + function contentCallBack(result) { + var handlerNode = document.getElementById("ReturnedContent"); + handlerNode.innerHTML = "<p>" + result + "</p>" ; + } + + var helloWorldService = new dojo.rpc.JsonService("services/HelloWorldService?smd"); + + </script> + + </body> +</html> diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..be750ec461 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ +<?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://sample"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:helloworldjsonrpc"/>
+</contribution>
+
diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..2c0c79726d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + * 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. +--> + +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web +Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> +<web-app> + + + <display-name>Tuscany sample HelloWorld JSON-RPC</display-name> + + <welcome-file-list id="WelcomeFileList"> + <welcome-file>HelloWorldJSONRPC.html</welcome-file> + </welcome-file-list> + + <listener> + <listener-class>org.apache.tuscany.sca.webapp.TuscanyContextListener</listener-class> + </listener> + + +<servlet> + <servlet-name>TuscanyServlet</servlet-name> + <servlet-class>org.apache.tuscany.sca.webapp.TuscanyServlet</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>TuscanyServlet</servlet-name> + <url-pattern>/services/*</url-pattern> + </servlet-mapping> +</web-app> diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/style.css b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/style.css new file mode 100644 index 0000000000..7073905b11 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/helloworld-jsonrpc/src/main/webapp/style.css @@ -0,0 +1,4 @@ +* { font-family: arial; } + +table, th, td { border: 2px solid blue; border-collapse: collapse; } +th { color: white; background-color: blue; } |