summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.4/tutorials/store/store-eu
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-1.4/tutorials/store/store-eu')
-rw-r--r--branches/sca-java-1.4/tutorials/store/store-eu/META-INF/sca-contribution.xml26
-rw-r--r--branches/sca-java-1.4/tutorials/store/store-eu/pom.xml111
-rw-r--r--branches/sca-java-1.4/tutorials/store/store-eu/store-eu.composite70
-rw-r--r--branches/sca-java-1.4/tutorials/store/store-eu/uiservices/store-eu.html162
4 files changed, 369 insertions, 0 deletions
diff --git a/branches/sca-java-1.4/tutorials/store/store-eu/META-INF/sca-contribution.xml b/branches/sca-java-1.4/tutorials/store/store-eu/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..552932b0e7
--- /dev/null
+++ b/branches/sca-java-1.4/tutorials/store/store-eu/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"
+ xmlns:s="http://store">
+ <import.java package="services"/>
+ <import.java package="services.merger"/>
+ <import.java package="services.db"/>
+ <deployable composite="s:store-eu"/>
+</contribution> \ No newline at end of file
diff --git a/branches/sca-java-1.4/tutorials/store/store-eu/pom.xml b/branches/sca-java-1.4/tutorials/store/store-eu/pom.xml
new file mode 100644
index 0000000000..b689c888e6
--- /dev/null
+++ b/branches/sca-java-1.4/tutorials/store/store-eu/pom.xml
@@ -0,0 +1,111 @@
+<?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-tutorial-store</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tutorial-store-eu</artifactId>
+ <name>Apache Tuscany SCA Store Tutorial EU Online Store</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-sca-api</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <sourceDirectory>${basedir}</sourceDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ <exclude>**/.*/**</exclude>
+ <exclude>pom.xml</exclude>
+ <exclude>build.xml</exclude>
+ <exclude>target/**</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-maven-ant-generator</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sql-maven-plugin</artifactId>
+ <version>1.0</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.3.1.4</version>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>create-db</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+ <url>jdbc:derby:${basedir}/target/cart-eu-db;create=true</url>
+ <autocommit>true</autocommit>
+ <onError>continue</onError>
+ <delimiter>;</delimiter>
+ <srcFiles>
+ <srcFile>${basedir}/../assets/services/db/cart.sql</srcFile>
+ </srcFiles>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/branches/sca-java-1.4/tutorials/store/store-eu/store-eu.composite b/branches/sca-java-1.4/tutorials/store/store-eu/store-eu.composite
new file mode 100644
index 0000000000..a0b8b50975
--- /dev/null
+++ b/branches/sca-java-1.4/tutorials/store/store-eu/store-eu.composite
@@ -0,0 +1,70 @@
+<?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="store-eu">
+
+ <component name="StoreEU">
+ <t:implementation.widget location="uiservices/store-eu.html"/>
+ <service name="Widget">
+ <t:binding.http uri="/ui"/>
+ </service>
+ <reference name="catalog" target="StoreEUCatalog">
+ <t:binding.jsonrpc/>
+ </reference>
+ <reference name="shoppingCart" target="StoreEUShoppingCart/Cart">
+ <t:binding.atom/>
+ </reference>
+ <reference name="shoppingTotal" target="StoreEUShoppingCart/Total">
+ <t:binding.jsonrpc/>
+ </reference>
+ </component>
+
+ <component name="StoreEUCatalog">
+ <implementation.java class="services.merger.MergedCatalogImpl"/>
+ <property name="currencyCode">EUR</property>
+ <service name="Catalog">
+ <t:binding.jsonrpc/>
+ <binding.ws uri="/CatalogWebService"/>
+ </service>
+ <reference name="fruitsCatalog" target="FruitsCatalogWebService">
+ <binding.ws/>
+ </reference>
+ <reference name="vegetablesCatalog" target="VegetablesCatalogWebService">
+ <binding.ws/>
+ </reference>
+ <reference name="currencyConverter" target="CurrencyConverterWebService">
+ <binding.ws/>
+ </reference>
+ </component>
+
+ <component name="StoreEUShoppingCart">
+ <implementation.java class="services.db.ShoppingCartTableImpl"/>
+ <property name="database">../store-eu/target/cart-eu-db</property>
+ <service name="Cart">
+ <t:binding.atom uri="/ShoppingCart/Cart"/>
+ </service>
+ <service name="Total">
+ <t:binding.jsonrpc/>
+ </service>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.4/tutorials/store/store-eu/uiservices/store-eu.html b/branches/sca-java-1.4/tutorials/store/store-eu/uiservices/store-eu.html
new file mode 100644
index 0000000000..4569b76b3f
--- /dev/null
+++ b/branches/sca-java-1.4/tutorials/store/store-eu/uiservices/store-eu.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>EU Store</title>
+
+<script type="text/javascript" src="store-eu.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);
+ }
+ carch(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>
+ <p>Fruits and Vegetables - Fruits et Legumes - Obst und Gemuese
+ <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>