You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2006/10/30 11:30:01 UTC

svn commit: r469108 - in /incubator/tuscany/java/samples/sca/helloworldjsonrpc: build.xml pom.xml src/main/webapp/HelloWorldJSONRPC.html src/main/webapp/style.css

Author: antelder
Date: Mon Oct 30 02:30:01 2006
New Revision: 469108

URL: http://svn.apache.org/viewvc?view=rev&rev=469108
Log:
TUSCANY-884, apply patch from Bert Lamb: Add Dojo support to jsonrpc binding

Added:
    incubator/tuscany/java/samples/sca/helloworldjsonrpc/build.xml
    incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/style.css
Modified:
    incubator/tuscany/java/samples/sca/helloworldjsonrpc/pom.xml
    incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/HelloWorldJSONRPC.html

Added: incubator/tuscany/java/samples/sca/helloworldjsonrpc/build.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldjsonrpc/build.xml?view=auto&rev=469108
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldjsonrpc/build.xml (added)
+++ incubator/tuscany/java/samples/sca/helloworldjsonrpc/build.xml Mon Oct 30 02:30:01 2006
@@ -0,0 +1,81 @@
+<?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="unpack-dojo-files" depends="check-dojo-installed, check-dojo-unpacked" unless="already.unpacked">
+        <fail message="dojo zip file not installed in local repository" 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>

Modified: incubator/tuscany/java/samples/sca/helloworldjsonrpc/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldjsonrpc/pom.xml?view=diff&rev=469108&r1=469107&r2=469108
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldjsonrpc/pom.xml (original)
+++ incubator/tuscany/java/samples/sca/helloworldjsonrpc/pom.xml Mon Oct 30 02:30:01 2006
@@ -50,6 +50,56 @@
     <build>
         <finalName>sample-helloworldjsonrpc</finalName>
         <plugins>
+        <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution> 
+                        <id>install-dojo</id>                       
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                        <configuration>
+                            <tasks>
+                                <ant 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 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 target="clean-dojo-files">
+                                    <property name="localRepository" value="${settings.localRepository}"/>
+                                    <property name="artifactId" value="${artifactId}"/>
+                                </ant>
+                            </tasks>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>            
             <plugin>
                 <groupId>org.apache.tuscany.sca.plugins</groupId>
                 <artifactId>tuscany-war-plugin</artifactId>

Modified: incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/HelloWorldJSONRPC.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/HelloWorldJSONRPC.html?view=diff&rev=469108&r1=469107&r2=469108
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/HelloWorldJSONRPC.html (original)
+++ incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/HelloWorldJSONRPC.html Mon Oct 30 02:30:01 2006
@@ -19,6 +19,11 @@
  -->
   <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>
 
@@ -31,23 +36,101 @@
           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 Example</h2><br>
+    <h2>Tuscany JSON-RPC HelloWorld Examples</h2>
      
-    <p>
-      Name please: &nbsp;&nbsp;&nbsp;
-      <input type="text" id="name" size="30" value="World" />
-
-      <br><BR>
-
-      <input type="button" value="Submit" onclick="getGreeting()" />
-    </p>
-        
-    <br><hr>
-    <div id='greeting'></div>
+    <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 
+           <a href="services/HelloWorldJSONService">services/HelloWorldJSONService</a>
+      </tr>
+      <tr>
+        <td>Request</td>
+        <td>Response</td>
+      </tr>
+      <tr>
+        <td>
+            <p>
+              Name please: &nbsp;&nbsp;&nbsp;
+              <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
+           <a href="services/HelloWorldJSONService">services/HelloWorldJSONService</a>
+           using <a href="http://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book9">Dojo's RPC classes</a>
+           and providing them with <a href="services/HelloWorldJSONService?smd">services/HelloWorldJSONService?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/HelloWorldJSONService?smd");
+    
+    </script>
        
   </body>
 </html>

Added: incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/style.css
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/style.css?view=auto&rev=469108
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/style.css (added)
+++ incubator/tuscany/java/samples/sca/helloworldjsonrpc/src/main/webapp/style.css Mon Oct 30 02:30:01 2006
@@ -0,0 +1,4 @@
+* { font-family: arial; }
+
+table, th, td { border: 2px solid blue; border-collapse: collapse; }
+th { color: white; background-color: blue; }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org