diff options
Diffstat (limited to 'sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC')
6 files changed, 455 insertions, 0 deletions
diff --git a/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..15bab17c1a --- /dev/null +++ b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/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://store" + xmlns:store="http://store"> + <deployable composite="store:storeC"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/index.js b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/index.js new file mode 100644 index 0000000000..d42dc5512d --- /dev/null +++ b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/index.js @@ -0,0 +1,66 @@ +/*-----------------------------------------------------------------------------+ +| Product: index.js - Ajile's default auto-loader for shared dependencies. +|+-----------------------------------------------------------------------------+ +| Author: Michael A. I. Lee [ http://ajile.iskitz.com/ ] +| +| Created: Friday, November 2, 2006 [2006.06.02 - 19:44:40 EDT] +| Modified: Saturday December 16, 2006 [2006.12.16 - 13:00:00 EST] +|+-----------------------------------------------------------------------------+ +| +| README: +| +| If you need a way to import/load a common set of scripts for every page on +| your site or in your web application, this is the file you should use. +| +| This index.js file can be used to define scripting dependencies for a page, +| site, or application in a single place for use in many places. +| +| As of Ajile 0.6.5, Ajile automatically loads the index.js file found in its +| directory. To disable this behavior, use the "mvcshareoff" load-time option +| in the src parameter of the script tag used to load Ajile. +| +| Placing your top-level Namespace, Import, and Load directives in this file +| allows Ajile to automatically load, import, and initialize all required +| modules at startup for every page that uses Ajile. +| +| By using this file as described, all scripting logic can be controlled from +| a single point separate from the page, site or application's display logic. +| +| When used within web pages (e.g. HTML, XHTML, HTA, JSP, ASP, PHP, CGI, etc.) +| only 1 SCRIPT tag is required. That SCRIPT tag must identify the location of +| the Ajile module. For example: +| +| <script type="text/javascript" src="__Ajile's_Path__"></script> +| +| Visit http://ajile.iskitz.com/ to start creating "Smart scripts that play nice!" +|+----------------------------------------------------------------------------*/ + +// You may copy this file into your own projects and use it to define your +// shared dependencies. This file must reside in the same location as the Ajile +// module. The logic below demonstrates how this file can be used to define an +// auto-loader. You'll most-likely use index.js to auto-load common or shared +// functionality. + +/* + + // Example options setting... + Ajile.EnableCloak(false); + Ajile.EnableDebug(); + Ajile.EnableOverride(false); + + // Define your namespace. + Namespace ("your.namespace"); + + // Import a versioned namespace. + Import ("some.namespace.*.0.6", "some/path/"); + + // Import a module's public members. + Import ("some.other.Module.*"); + + // Define a new module. + your.namespace.NewModule = new function() + { + // Your implementation here... + }; + +//*/
\ No newline at end of file diff --git a/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/store.html b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/store.html new file mode 100644 index 0000000000..0e3ab370b3 --- /dev/null +++ b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/store.html @@ -0,0 +1,114 @@ +<!-- + * 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="http://luck.ibm.com:8400/store/nodeC/store.js"></script> + +<script language="JavaScript"> + +var propertyMap = new Object(); +function Property(name) { + return propertyMap[name]; +} +var referenceMap = new Object(); +function Reference(name) { + return referenceMap[name]; +} + +alert("PropertyMap : " + propertyMap); +alert("ReferenceMap: " + referenceMap); + +//dhtmlLoadScript("http://luck.ibm.com:8100/store/nodeA/store.js"); +staticLoadScript("http://luck.ibm.com:8100/store/nodeA/store.js"); + +referenceMap.catalog = referenceMapA.catalog; +</script> + +</head> + +<body> +<h1>Store</h1> + + <input type="button" onClick="init()" value"Initialize"> + + <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/Cart/">(feed)</a> + </form> + </div> + +</body> + + + +<script language="JavaScript"> + + //@Reference + var catalog = new Reference("catalog"); + + var catalogItems; + + function catalog_getResponse(items,exception) { + if(exception){ + alert(exception.message); + return; + } + var catalog = ""; + + for (var i=0; i<items.length; i++) { + var item = items[i].name + ' - ' + items[i].price; + catalog += '<input name="items" type="checkbox" value="' + + item + '">' + item + ' <br>'; + } + document.getElementById('catalog').innerHTML=catalog; + catalogItems = items; + } + + function init() { + + alert(Reference("catalog")); + try { + catalog.get(catalog_getResponse); + } + catch(e){ + alert(e); + } + } + + init(); +</script> + +</html> diff --git a/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/store.js b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/store.js new file mode 100644 index 0000000000..088a80a1d1 --- /dev/null +++ b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/content/store.js @@ -0,0 +1,39 @@ + +function dhtmlLoadScript(url) { + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + document.getElementsByTagName('head')[0].appendChild(script); +} + +function dhtmlLoadScriptIFrame(iframeId, url) { + var iframe = document.createElement("IFRAME"); + iframe.style.display="none"; + iframe.name = iframeId; + iframe.id = iframeId; + iframe.src = url; + document.body.appendChild(iframe); + + //var iframeDocument = window.frames[iframeId].document; + //iframeDocument.write('<script src="', url, '" type="text/JavaScript"><\/script>'); +} + + +function staticLoadScript(url) +{ + document.write('<script src="', url, '" type="text/JavaScript"><\/script>'); +} + + +function initialize() { + + + //alert('will load sotre.js from nodeA'); + //dhtmlLoadScriptIFrame("iframe", "http://localhost:8100/store/nodeA/store.html"); + + //alert('will load sotre.js from nodeB'); + //dhtmlLoadScriptIFrame("iframe2","http://localhost:8200/store/nodeB/store.html"); +} + +/** End of Apache Tuscany SCA Widget */ + diff --git a/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/store.composite b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/store.composite new file mode 100644 index 0000000000..aa603114a6 --- /dev/null +++ b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/store.composite @@ -0,0 +1,50 @@ +<?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" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://store" + name="storeC"> + + <component name="Store"> + <t:implementation.widget location="content/store.html"/> + <service name="Widget"> + <t:binding.http uri="/store"/> + </service> + <reference name="catalog" target="Catalog"> + <t:binding.jsonrpc/> + </reference> + <reference name="shoppingCart" target="ShoppingCart/Cart"> + <t:binding.atom/> + </reference> + <reference name="shoppingTotal" target="ShoppingCart/Total"> + <t:binding.jsonrpc/> + </reference> + </component> + + <!-- http://localhost:8400/store/nodeA/store.js --> + <component name="jsNodeC"> + <t:implementation.resource location="content"/> + <service name="Resource"> + <t:binding.http uri="/store/nodeC"/> + </service> + </component> + +</composite> + diff --git a/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/uiservices/store.html b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/uiservices/store.html new file mode 100644 index 0000000000..45604463d1 --- /dev/null +++ b/sandbox/lresende/sca/samples/store-distributed/src/main/resources/nodeC/uiservices/store.html @@ -0,0 +1,162 @@ +<!-- + * 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="store.js"></script> + +<script language="JavaScript"> + + //@Reference + var catalog = new Reference("catalog"); + + //@Reference + var shoppingCart = new Reference("shoppingCart"); + + //@Reference + var shoppingTotal = new Reference("shoppingTotal"); + + var catalogItems; + + function catalog_getResponse(items,exception) { + if(exception){ + alert(exception.message); + return; + } + var catalog = ""; + + for (var i=0; i<items.length; i++) { + var item = items[i].name + ' - ' + items[i].price; + catalog += '<input name="items" type="checkbox" value="' + + item + '">' + item + ' <br>'; + } + document.getElementById('catalog').innerHTML=catalog; + catalogItems = items; + } + + function shoppingCart_getResponse(feed) { + if (feed != null) { + var entries = feed.getElementsByTagName("entry"); + var list = ""; + for (var i=0; i<entries.length; i++) { + var content = entries[i].getElementsByTagName("content")[0]; + var name = content.getElementsByTagName("name")[0].firstChild.nodeValue; + var price = content.getElementsByTagName("price")[0].firstChild.nodeValue; + list += name + ' - ' + price + ' <br>'; + } + document.getElementById("shoppingCart").innerHTML = list; + + if (entries.length != 0) { + try { + shoppingTotal.getTotal(shoppingTotal_getTotalResponse); + } + catch(e){ + alert(e); + } + } + } + } + + function shoppingTotal_getTotalResponse(total,exception) { + if(exception) { + alert(exception.message); + return; + } + document.getElementById('total').innerHTML = total; + } + + 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>item</title><content type="text/xml">' + + '<Item xmlns="http://services/">' + + '<name xmlns="">' + catalogItems[i].name + '</name>' + '<price xmlns="">' + catalogItems[i].price + '</price>' + + '</Item>' + '</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">'+ + 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 = ""; + } + + function init() { + + try { + catalog.get(catalog_getResponse); + shoppingCart.get("", shoppingCart_getResponse); + } + catch(e){ + alert(e); + } + } + +</script> + +</head> + +<body onload="init()"> +<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/Cart/">(feed)</a> + </form> + </div> +</body> +</html> |