summaryrefslogtreecommitdiffstats
path: root/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war')
-rw-r--r--sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/META-INF/sca-contribution.xml26
-rw-r--r--sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/appengine-web.xml29
-rw-r--r--sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/logging.properties37
-rw-r--r--sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/web.xml42
-rw-r--r--sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/log4j.properties28
-rw-r--r--sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.composite68
-rw-r--r--sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.css22
-rw-r--r--sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.html194
8 files changed, 446 insertions, 0 deletions
diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/META-INF/sca-contribution.xml b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..f3b6c89fe0
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:store="http://store">
+
+ <deployable composite="store:catalog" />
+ <!-- import.java package="services" / -->
+</contribution> \ No newline at end of file
diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/appengine-web.xml b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/appengine-web.xml
new file mode 100644
index 0000000000..0e5f6fc072
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/appengine-web.xml
@@ -0,0 +1,29 @@
+<?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.
+-->
+<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
+ <application>tuscany-store-merger</application>
+ <version>1</version>
+
+ <!-- Configure java.util.logging -->
+ <system-properties>
+ <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
+ </system-properties>
+
+</appengine-web-app> \ No newline at end of file
diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/logging.properties b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/logging.properties
new file mode 100644
index 0000000000..bd3b8308fc
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/logging.properties
@@ -0,0 +1,37 @@
+#
+#
+# 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.
+#
+#
+# A default java.util.logging configuration.
+# (All App Engine logging is through java.util.logging by default).
+#
+# To use this configuration, copy it into your application's WEB-INF
+# folder and add the following to your appengine-web.xml:
+#
+# <system-properties>
+# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
+# </system-properties>
+#
+
+# Set the default logging level for all loggers to WARNING
+.level = WARNING
+
+#tuscany debug messages
+org.apache.tuscany.level = WARNING
+
diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/web.xml b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/web.xml
new file mode 100644
index 0000000000..31fc39a160
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<!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>
+
+ <!-- Tuscany Filter -->
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <!-- Default page to serve -->
+ <welcome-file-list>
+ <welcome-file>store.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/log4j.properties b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/log4j.properties
new file mode 100644
index 0000000000..036b48afd7
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/log4j.properties
@@ -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.
+#
+#
+
+# Configure the console as our one appender
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
+
+#tuscany debug messages
+log4j.category.org.apache.tuscany=ALL,A1
diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.composite b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.composite
new file mode 100644
index 0000000000..5671c81f1a
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.composite
@@ -0,0 +1,68 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:s="http://store"
+ targetNamespace="http://store"
+ name="catalog">
+
+ <component name="CatalogAggregator">
+ <implementation.java class="services.CatalogAggregatorImpl"/>
+ <property name="currencyCode">USD</property>
+ <service name="Catalog">
+ <interface.java interface="services.Catalog"/>
+ <tuscany:binding.jsonrpc uri="/Catalog"/>
+ </service>
+ <reference name="fruitsCatalog">
+ <interface.java interface="services.Catalog"/>
+ <tuscany:binding.jsonrpc uri="http://tuscany-store-catalog.appspot.com/Catalog"/>
+ </reference>
+ <reference name="vegetablesCatalog">
+ <interface.java interface="services.Catalog"/>
+ <tuscany:binding.jsonrpc uri="http://tuscany.figueiredos.com/store-catalog-ibmcloud-webapp/Catalog"/>
+ </reference>
+ <reference name="currencyConverter" target="CurrencyConverter" />
+ </component>
+
+ <component name="CurrencyConverter">
+ <implementation.java class="services.CurrencyConverterImpl" />
+ <service name="CurrencyConverter">
+ <interface.java interface="services.CurrencyConverter"/>
+ </service>
+ </component>
+
+ <component name="ShoppingCartManager">
+ <implementation.java class="services.ShoppingCartManager"/>
+ <service name="ShoppingCart">
+ <tuscany:binding.jsonrpc uri="/ShoppingCart"/>
+ </service>
+ <reference name="userService" target="UserService">
+ <binding.sca name="local"/>
+ </reference>
+ </component>
+
+ <component name="UserService">
+ <implementation.java class="org.apache.tuscany.sca.cloud.user.impl.GoogleUserService"/>
+ <service name="UserService">
+ <binding.sca name="local"/>
+ <tuscany:binding.jsonrpc uri="/User"/>
+ </service>
+ </component>
+</composite>
diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.css b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.css
new file mode 100644
index 0000000000..0b1d541bea
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.css
@@ -0,0 +1,22 @@
+<style type="text/css">
+
+html, body {
+ height:100%;
+ margin:0;
+ overflow:hidden;
+ width:100%;
+}
+
+.header {
+ font-size:13px;
+ text-align:right;
+ color:#CCCCCC;
+
+
+ padding:5px 5px 0;
+ padding-right:8px;
+ padding-top:0px !important;
+ padding-bottom: 0px;
+ border-bottom: 1px solid black;
+}
+</style> \ No newline at end of file
diff --git a/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.html b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.html
new file mode 100644
index 0000000000..aadb4ebd4f
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-merger-appengine-webapp/war/store.html
@@ -0,0 +1,194 @@
+<!--
+ * 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>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<title>Online Store - Powered by Apache Tuscany</title>
+
+<link href="store.css" rel="stylesheet" type="text/css">
+
+<script type="text/javascript" src="dojo/dojo/dojo.js"></script>
+
+<script type="text/javascript">
+ dojo.require("dojo.rpc.JsonService");
+</script>
+
+<script language="JavaScript">
+
+ var userServices = new dojo.rpc.JsonService("/User?smd");
+
+ var catalog = new dojo.rpc.JsonService("/Catalog?smd");
+
+ var shoppingCart = new dojo.rpc.JsonService("/ShoppingCart?smd");
+
+ var userContext;
+
+ var catalogItems;
+
+ function showHeader() {
+ var userContextCallback = function(context) {
+ userContext = context;
+ //alert(userContext.userId + " --> " + userContext.loginUrl);
+
+ var html='';
+ if(! userContext.userId) {
+ html = "<a href='" + userContext.loginUrl +"'>Login</a>";
+ } else {
+ html = userContext.email + " | <a href='" + userContext.logoutUrl +"'> Logout</a>";
+ }
+
+ document.getElementById('appHeader').innerHTML = html;
+ }
+
+ userServices.getUserContext(document.URL, "").addCallback(userContextCallback);
+ }
+
+ function showCatalogs() {
+ var catalogCallback = function(items) {
+ var catalog = "";
+ for (var i=0; i<items.length; i++) {
+ var item = items[i].name + ' - ' + items[i].currencySymbol + items[i].price;
+ catalog += '<input name="items" type="checkbox" value="' +
+ item + '">' + item + ' <br>';
+ }
+ document.getElementById('catalog').innerHTML=catalog;
+ catalogItems = items;
+ }
+
+ catalog.get().addCallback(catalogCallback);
+ }
+
+
+ // This handles the response from shoppingCart.getAll
+ // which is a collection of Entry<K,D>
+ function shoppingCart_getResponse(items) {
+ var list='';
+ for (var i=0; i<items.length; i++) {
+ //get the actual item, that is Entry.data
+ var item = items[i].data;
+ // process its attributes
+ var name = item.name;
+ var symbol = item.currencySymbol;
+ var price = item.price
+ list += name + ' - ' + symbol + price + ' <br>';
+ }
+ document.getElementById("shoppingCart").innerHTML = list;
+
+ if (items.length != 0) {
+ try {
+ shoppingCart.getTotal().addCallback(shoppingCart_getTotalResponse);
+ }
+ catch(e){
+ alert(e);
+ }
+ }
+ }
+
+ function shoppingCart_getTotalResponse(total,exception) {
+ if(exception) {
+ alert(exception.message);
+ return;
+ }
+ document.getElementById('total').innerHTML = total;
+ }
+
+ function shoppingCart_postResponse(entry) {
+ shoppingCart.getAll().addCallback(shoppingCart_getResponse);
+ }
+
+ function addToCart() {
+ var items = document.catalogForm.items;
+ var j = 0;
+ for (var i=0; i<items.length; i++)
+ if (items[i].checked) {
+ shoppingCart.post("", catalogItems[i]).addCallback(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.delete("");
+ }
+ function deleteCart() {
+ shoppingCart.delete("");
+ document.getElementById('shoppingCart').innerHTML = "";
+ document.getElementById('total').innerHTML = "";
+ }
+
+
+
+ function init() {
+ try {
+ showHeader();
+
+ showCatalogs();
+
+ shoppingCart.getAll().addCallback(shoppingCart_getResponse);
+ } catch (e) {
+ alert(e);
+ }
+ }
+
+
+</script>
+
+</head>
+
+<body onload="init()">
+ <div id="appHeader" class="header">
+ </div>
+
+ <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">
+ </form>
+ </div>
+</body>
+
+</html> \ No newline at end of file