You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2007/10/28 00:34:59 UTC
svn commit: r589231 - in
/incubator/tuscany/java/sca/modules/implementation-widget: ./
src/main/java/org/apache/tuscany/sca/implementation/widget/
src/test/java/org/apache/tuscany/sca/implementation/widget/
src/test/resources/ src/test/resources/content/
Author: lresende
Date: Sat Oct 27 15:34:56 2007
New Revision: 589231
URL: http://svn.apache.org/viewvc?rev=589231&view=rev
Log:
Updates to the generated js to support new Reference("catalog") on the html client
Added:
incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java (with props)
incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/content/store.html (with props)
Modified:
incubator/tuscany/java/sca/modules/implementation-widget/pom.xml
incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java
incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetReferenceServlet.java
incubator/tuscany/java/sca/modules/implementation-widget/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java
incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/widget.composite
Modified: incubator/tuscany/java/sca/modules/implementation-widget/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/pom.xml?rev=589231&r1=589230&r2=589231&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/implementation-widget/pom.xml Sat Oct 27 15:34:56 2007
@@ -56,6 +56,12 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-feed</artifactId>
<version>1.1-incubating-SNAPSHOT</version>
</dependency>
Modified: incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java?rev=589231&r1=589230&r2=589231&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java Sat Oct 27 15:34:56 2007
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.implementation.widget;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Added: incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java?rev=589231&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java Sat Oct 27 15:34:56 2007
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.tuscany.sca.implementation.widget;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class WidgetProxyHelper {
+ protected static Map<String, String> proxyFileRegistry = new HashMap<String, String>();
+ protected static Map<String, String> proxyClient = new HashMap<String, String>();
+
+ static {
+ proxyFileRegistry.put("org.apache.tuscany.sca.binding.feed.impl.AtomBindingImpl", "binding-atom.js");
+ proxyClient.put("org.apache.tuscany.sca.binding.feed.impl.AtomBindingImpl", "AtomBindingClient");
+
+ //proxyRegistry.put("org.apache.tuscany.sca.binding.feed.impl.AtomBindingImpl", "binding-jsonrpc.js");
+ //proxyClient.put("org.apache.tuscany.sca.binding.feed.impl.AtomBindingImpl", "JSONRPCBindingClient");
+ }
+
+ protected WidgetProxyHelper() {
+
+ }
+
+ public static String getJavaScriptProxyFile(String bindingClass) {
+ return proxyFileRegistry.get(bindingClass);
+ }
+
+ public static String getJavaScriptProxyClient(String bindingClass) {
+ return proxyClient.get(bindingClass);
+ }
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetProxyHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetReferenceServlet.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetReferenceServlet.java?rev=589231&r1=589230&r2=589231&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetReferenceServlet.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetReferenceServlet.java Sat Oct 27 15:34:56 2007
@@ -21,8 +21,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
@@ -39,12 +37,10 @@
* @version $Rev$ $Date$
*/
public class WidgetReferenceServlet extends HttpServlet {
- protected transient Map<String, String> proxyRegistry = new HashMap<String, String>();
+
protected transient RuntimeComponent component;
public WidgetReferenceServlet(RuntimeComponent component) {
- proxyRegistry.put("org.apache.tuscany.sca.binding.feed.impl.AtomBindingImpl", "binding-atom.js");
- //proxyRegistry.put("org.apache.tuscany.sca.binding.feed.impl.AtomBindingImpl", "binding-jsonrpc.js");
this.component = component;
}
@@ -72,12 +68,8 @@
for(ComponentReference reference : component.getReferences()) {
String referenceName = reference.getName();
- out.println("Reference::" + referenceName);
for(Binding binding : reference.getBindings()) {
- out.println("::Bind::" + binding.getName());
- out.println("::Bind class::" + binding.getClass());
-
- String bindingProxyName = proxyRegistry.get(binding.getClass().getName());
+ String bindingProxyName = WidgetProxyHelper.getJavaScriptProxyFile(binding.getClass().getName());
if(bindingProxyName != null) {
writeJavaScriptBindingProxy(out,bindingProxyName);
}
@@ -109,6 +101,17 @@
}
protected void writeJavaScriptReferenceFunction (ServletOutputStream os) throws IOException {
+
+ for(ComponentReference reference : component.getReferences()) {
+ String referenceName = reference.getName();
+ Binding binding = reference.getBindings().get(0);
+ if( binding != null) {
+ String proxyClient = WidgetProxyHelper.getJavaScriptProxyClient(binding.getClass().getName());
+ if(proxyClient != null) {
+ os.println("proxy[" + referenceName + "]= new " + proxyClient + "(\"" + binding.getURI() + "\");");
+ }
+ }
+ }
os.println("function Reference(name) {");
os.println(" return proxy[name];");
Modified: incubator/tuscany/java/sca/modules/implementation-widget/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java?rev=589231&r1=589230&r2=589231&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-widget/src/test/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationTestCase.java Sat Oct 27 15:34:56 2007
@@ -43,7 +43,7 @@
public void testPing() throws Exception {
new Socket("127.0.0.1", 8080);
- System.in.read();
+ //System.in.read();
}
}
Added: incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/content/store.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/content/store.html?rev=589231&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/content/store.html (added)
+++ incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/content/store.html Sat Oct 27 15:34:56 2007
@@ -0,0 +1,122 @@
+<!--
+ * 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.
+-->
+<html>
+<head>
+<title>Store</TITLE>
+
+<script type="text/javascript" src="binding-atom.js"></script>
+<script type="text/javascript" src="binding-jsonrpc.js"></script>
+
+<!-- one js include per sca component -->
+<script type="text/javascript" src="storeWidgetComponent.js"/>
+
+<script language="JavaScript">
+
+ //@Reference
+ var catalog = new Reference("catalog"); //(new JSONRpcClient("../Catalog")).Catalog;
+ //@Reference
+ var shoppingCart = new Reference("shoppingCart"); //new AtomClient("../ShoppingCart");
+
+
+ function catalog_getResponse(items) {
+ var catalog = "";
+ for (var i=0; i<items.length; i++)
+ catalog += '<input name="items" type="checkbox" value="' +
+ items[i] + '">' + items[i]+ ' <br>';
+ document.getElementById('catalog').innerHTML=catalog;
+ }
+
+ function shoppingCart_getResponse(feed) {
+ if (feed != null) {
+ var entries = feed.getElementsByTagName("entry");
+ var list = "";
+ for (var i=0; i<entries.length; i++) {
+ var item = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue;
+ list += item + ' <br>';
+ }
+ document.getElementById("shoppingCart").innerHTML = list;
+ document.getElementById('total').innerHTML = feed.getElementsByTagName("subtitle")[0].firstChild.nodeValue;
+ }
+ }
+ function shoppingCart_postResponse(entry) {
+ shoppingCart.get("", shoppingCart_getResponse);
+ }
+
+
+ function addToCart() {
+ var items = document.catalogForm.items;
+ var j = 0;
+ for (var i=0; i<items.length; i++)
+ if (items[i].checked) {
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title>cart-item</title><content type="text">'+items[i].value+'</content></entry>'
+ shoppingCart.post(entry, shoppingCart_postResponse);
+ items[i].checked = false;
+ }
+ }
+ function checkoutCart() {
+ document.getElementById('store').innerHTML='<h2>' +
+ 'Thanks for Shopping With Us!</h2>'+
+ '<h2>Your Order</h2>'+
+ '<form name="orderForm" action="/ufs/store.html">'+
+ document.getElementById('shoppingCart').innerHTML+
+ '<br>'+
+ document.getElementById('total').innerHTML+
+ '<br>'+
+ '<br>'+
+ '<input type="submit" value="Continue Shopping">'+
+ '</form>';
+ shoppingCart.del("", null);
+ }
+ function deleteCart() {
+ shoppingCart.del("", null);
+ document.getElementById('shoppingCart').innerHTML = "";
+ document.getElementById('total').innerHTML = "";
+ }
+
+ catalog.get(catalog_getResponse);
+ shoppingCart.get("", shoppingCart_getResponse);
+</script>
+
+</head>
+
+<body>
+<h1>Store</h1>
+ <div id="store">
+ <h2>Catalog</h2>
+ <form name="catalogForm">
+ <div id="catalog" ></div>
+ <br>
+ <input type="button" onClick="addToCart()" value="Add to Cart">
+ </form>
+
+ <br>
+
+ <h2>Your Shopping Cart</h2>
+ <form name="shoppingCartForm">
+ <div id="shoppingCart"></div>
+ <br>
+ <div id="total"></div>
+ <br>
+ <input type="button" onClick="checkoutCart()" value="Checkout">
+ <input type="button" onClick="deleteCart()" value="Empty">
+ <a href="../ShoppingCart/">(feed)</a>
+ </form>
+ </div>
+</body>
+</html>
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/content/store.html
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/content/store.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Modified: incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/widget.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/widget.composite?rev=589231&r1=589230&r2=589231&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/widget.composite (original)
+++ incubator/tuscany/java/sca/modules/implementation-widget/src/test/resources/widget.composite Sat Oct 27 15:34:56 2007
@@ -23,20 +23,23 @@
xmlns:sr="http://sample/resource"
name="resource">
- <component name="webWidgetComponent">
+ <component name="storeWidgetComponent">
<tuscany:implementation.widget location="content/store.html"/>
+ <service name="Widget">
+ <tuscany:binding.http/>
+ </service>
<!-- reference name="catalog" target="Catalog">
<tuscany:binding.jsonrpc/>
</reference-->
<reference name="shoppingCart" target="ShoppingCart">
- <tuscany:binding.atom/>
+ <tuscany:binding.atom uri="/ShoppingCart"/>
</reference>
</component>
<component name="Catalog">
<implementation.java class="store.CatalogImpl"/>
<service name="Catalog">
- <tuscany:binding.jsonrpc/>
+ <tuscany:binding.jsonrpc uri="/Catalog"/>
</service>
</component>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org