summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-10-23 17:56:00 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-10-23 17:56:00 +0000
commita6e0a1a959b837f1441de68e070f53dee9e35a55 (patch)
treecc0a0d394b0df259c43c7b3001a48bd3ed4e67c1
parentf60bcd37dc61721f97fd2f3f99c62c16e0125513 (diff)
Updating store with new vegetables catalog and adding basic support for shoppingCart services using JSON-RPC
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@829149 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath14
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/.project11
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs2
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml12
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties37
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java28
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java19
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java12
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java19
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java19
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java19
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java112
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java29
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite14
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml20
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties35
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml18
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html108
18 files changed, 480 insertions, 48 deletions
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath b/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath
index ccc7355a00..b9a1844d52 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="war/WEB-INF/lib/tuscany-sca-api-2.0-SNAPSHOT.jar"/>
- <classpathentry kind="output" path="war/WEB-INF/classes"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="war/WEB-INF/lib/tuscany-sca-api-2.0-SNAPSHOT.jar"/>
+ <classpathentry kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-cloud-api"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-cloud-google"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/tuscany-data-api"/>
+ <classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>
-
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project b/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project
index 974c61f3ad..3f44f6483e 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project
@@ -21,19 +21,24 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>com.google.appengine.eclipse.core.projectValidator</name>
+ <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
+ <name>com.google.appengine.eclipse.core.enhancerbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.appengine.eclipse.core.projectValidator</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.google.appengine.eclipse.core.gaeNature</nature>
<nature>com.google.gdt.eclipse.core.webAppNature</nature>
+ <nature>com.google.appengine.eclipse.core.gaeNature</nature>
</natures>
</projectDescription>
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs b/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs
index befefbd93b..c22fce6390 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs
@@ -1,4 +1,4 @@
-#Thu Oct 15 18:16:29 PDT 2009
+#Sun Oct 18 17:07:56 PDT 2009
eclipse.preferences.version=1
filesCopiedToWebInfLib=appengine-api-1.0-sdk-1.2.6.jar|appengine-api-labs-1.2.6.jar|datanucleus-appengine-1.0.3.jar|datanucleus-core-1.1.5.jar|datanucleus-jpa-1.1.5.jar|geronimo-jpa_3.0_spec-1.1.1.jar|geronimo-jta_1.1_spec-1.1.1.jar|jdo2-api-2.3-eb.jar
ormEnhancementInclusions=
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml b/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml
index 0a889520f5..332c861797 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml
@@ -35,7 +35,19 @@
<artifactId>tuscany-sca-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-cloud-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-cloud-google</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties
index f98cabf1b8..036b48afd7 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties
@@ -1,27 +1,28 @@
-# A default log4j configuration for log4j users.
#
-# To use this configuration, deploy it into your application's WEB-INF/classes
-# directory. You are also encouraged to edit it as you like.
+#
+# 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
-# tighten logging on the DataNucleus Categories
-log4j.category.DataNucleus.JDO=WARN, A1
-log4j.category.DataNucleus.Persistence=WARN, A1
-log4j.category.DataNucleus.Cache=WARN, A1
-log4j.category.DataNucleus.MetaData=WARN, A1
-log4j.category.DataNucleus.General=WARN, A1
-log4j.category.DataNucleus.Utility=WARN, A1
-log4j.category.DataNucleus.Transaction=WARN, A1
-log4j.category.DataNucleus.Datastore=WARN, A1
-log4j.category.DataNucleus.ClassLoading=WARN, A1
-log4j.category.DataNucleus.Plugin=WARN, A1
-log4j.category.DataNucleus.ValueGeneration=WARN, A1
-log4j.category.DataNucleus.Enhancer=WARN, A1
-log4j.category.DataNucleus.SchemaTool=WARN, A1
-
#tuscany debug messages
log4j.category.org.apache.tuscany=ALL,A1
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java
new file mode 100644
index 0000000000..3fb5439bc3
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java
@@ -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.
+ */
+
+package services;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Cart extends Collection<String, Item> {
+
+}
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java
index 2ecf9ae855..b8630370ad 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java
@@ -1,3 +1,22 @@
+/*
+ * 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 services;
import org.oasisopen.sca.annotation.Remotable;
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java
index 29c99bbcb5..09cae14100 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java
@@ -36,19 +36,29 @@ public class CatalogAggregatorImpl implements Catalog {
@Reference
public Catalog fruitsCatalog;
+
+ @Reference
+ public Catalog vegetablesCatalog;
public Item[] get() {
String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
Item[] fruits = fruitsCatalog.get();
+ Item[] vegetables = vegetablesCatalog.get();
- Item[] catalog = new Item[fruits.length];
+ Item[] catalog = new Item[fruits.length + vegetables.length];
int i =0;
for (Item item: fruits) {
double price = Double.valueOf(item.getPrice().substring(1));
price = currencyConverter.getConversion("USD", currencyCode, price);
catalog[i++] = new Item(item.getName(), currencySymbol + price);
}
+
+ for (Item item: vegetables) {
+ double price = Double.valueOf(item.getPrice().substring(1));
+ price = currencyConverter.getConversion("USD", currencyCode, price);
+ catalog[i++] = new Item(item.getName(), currencySymbol + price);
+ }
return catalog;
}
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java
index 07a152a276..59435d9099 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java
@@ -1,3 +1,22 @@
+/*
+ * 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 services;
import org.oasisopen.sca.annotation.Remotable;
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java
index 7de3894e2e..d185a2fe83 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java
@@ -1,3 +1,22 @@
+/*
+ * 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 services;
import org.oasisopen.sca.annotation.Service;
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java
index 65aaa53224..74e7239a20 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java
@@ -1,3 +1,22 @@
+/*
+ * 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 services;
import java.io.Serializable;
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java
new file mode 100644
index 0000000000..d06ee5b61b
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java
@@ -0,0 +1,112 @@
+/*
+ * 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 services;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class ShoppingCartImpl implements Cart, Total {
+
+ private Map<String, Item> cart;
+
+ @Init
+ public void init() {
+ cart = new HashMap<String, Item>();
+ }
+
+ public Entry<String, Item>[] getAll() {
+ Entry<String, Item>[] entries = new Entry[cart.size()];
+ int i = 0;
+ for (Map.Entry<String, Item> e: cart.entrySet()) {
+ entries[i++] = new Entry<String, Item>(e.getKey(), e.getValue());
+ }
+ return entries;
+ }
+
+ public Item get(String key) throws NotFoundException {
+ Item item = cart.get(key);
+ if (item == null) {
+ throw new NotFoundException(key);
+ } else {
+ return item;
+ }
+ }
+
+ public String post(String key, Item item) {
+ if (key == null || key.length() == 0) {
+ key ="cart-" + UUID.randomUUID().toString();
+ }
+ cart.put(key, item);
+ return key;
+ }
+
+ public void put(String key, Item item) throws NotFoundException {
+ if (!cart.containsKey(key)) {
+ throw new NotFoundException(key);
+ }
+ cart.put(key, item);
+ }
+
+ public void delete(String key) throws NotFoundException {
+ if (key == null || key.equals("")) {
+ cart.clear();
+ } else {
+ Item item = cart.remove(key);
+ if (item == null)
+ throw new NotFoundException(key);
+ }
+ }
+
+ public Entry<String, Item>[] query(String queryString) {
+ List<Entry<String, Item>> entries = new ArrayList<Entry<String,Item>>();
+ if (queryString.startsWith("name=")) {
+ String name = queryString.substring(5);
+ for (Map.Entry<String, Item> e: cart.entrySet()) {
+ Item item = e.getValue();
+ if (item.getName().equals(name)) {
+ entries.add(new Entry<String, Item>(e.getKey(), e.getValue()));
+ }
+ }
+ }
+ return entries.toArray(new Entry[entries.size()]);
+ }
+
+ public String getTotal() {
+ double total = 0;
+ String currencySymbol = "";
+ if (!cart.isEmpty()) {
+ Item item = cart.values().iterator().next();
+ currencySymbol = item.getPrice().substring(0, 1);
+ }
+ for (Item item : cart.values()) {
+ total += Double.valueOf(item.getPrice().substring(1));
+ }
+ return currencySymbol + String.valueOf(total);
+ }
+}
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java
new file mode 100644
index 0000000000..b77cc1c7ac
--- /dev/null
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java
@@ -0,0 +1,29 @@
+/*
+ * 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 services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Total {
+
+ String getTotal();
+
+}
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite
index 9a5897e87b..17df51b252 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite
@@ -34,6 +34,10 @@
<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-2x-webapp/Catalog"/>
+ </reference>
<reference name="currencyConverter" target="CurrencyConverter" />
</component>
@@ -43,4 +47,14 @@
<interface.java interface="services.CurrencyConverter"/>
</service>
</component>
+
+ <component name="ShoppingCart">
+ <implementation.java class="services.ShoppingCartImpl"/>
+ <service name="Cart">
+ <tuscany:binding.jsonrpc uri="/shoppingCart/Cart"/>
+ </service>
+ <service name="Total">
+ <tuscany:binding.jsonrpc uri="/shoppingCart/Total"/>
+ </service>
+ </component>
</composite>
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
index 2e265231e9..6c83c9666b 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
@@ -1,7 +1,25 @@
<?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</application>
- <version>1</version>
+ <version>3</version>
<!-- Configure java.util.logging -->
<system-properties>
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
index 411c7f2003..03808336ec 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
@@ -1,3 +1,23 @@
+#
+#
+# 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).
#
@@ -12,21 +32,6 @@
# Set the default logging level for all loggers to WARNING
.level = WARNING
-# Set the default logging level for ORM, specifically, to WARNING
-DataNucleus.JDO.level=WARNING
-DataNucleus.Persistence.level=WARNING
-DataNucleus.Cache.level=WARNING
-DataNucleus.MetaData.level=WARNING
-DataNucleus.General.level=WARNING
-DataNucleus.Utility.level=WARNING
-DataNucleus.Transaction.level=WARNING
-DataNucleus.Datastore.level=WARNING
-DataNucleus.ClassLoading.level=WARNING
-DataNucleus.Plugin.level=WARNING
-DataNucleus.ValueGeneration.level=WARNING
-DataNucleus.Enhancer.level=WARNING
-DataNucleus.SchemaTool.level=WARNING
-
#tuscany debug messages
org.apache.tuscany.level=WARNING
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml
index 31ad8abe98..31fc39a160 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml
@@ -1,4 +1,22 @@
<?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">
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
index cd9cff53a9..2fc5fcc434 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
@@ -1,6 +1,25 @@
+<!--
+ * 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>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<title>Online Store - Powered by Apache Tuscany</title>
<script type="text/javascript" src="dojo/dojo/dojo.js"></script>
@@ -11,6 +30,10 @@
<script language="JavaScript">
var catalog = new dojo.rpc.JsonService("/catalogAggregator?smd");
+
+ var shoppingCart = new dojo.rpc.JsonService("/shoppingCart/Cart?smd");
+
+ var shoppingTotal = new dojo.rpc.JsonService("/shoppingCart/Total?smd");
var catalogItems;
@@ -25,9 +48,76 @@
catalogItems = items;
}
+ // 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 price = item.price
+ list += name + ' - ' + price + ' <br>';
+ }
+ document.getElementById("shoppingCart").innerHTML = list;
+
+ if (items.length != 0) {
+ try {
+ shoppingTotal.getTotal().addCallback(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.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.del("");
+ }
+ function deleteCart() {
+ shoppingCart.del("");
+ document.getElementById('shoppingCart').innerHTML = "";
+ document.getElementById('total').innerHTML = "";
+ }
+
+
function init() {
try {
catalog.get().addCallback(catalog_getResponse);
+ shoppingCart.get("").addCallback(shoppingCart_getResponse);
} catch (e) {
alert(e);
}
@@ -44,10 +134,22 @@
<h2>Catalog</h2>
<form name="catalogForm">
<div id="catalog" ></div>
- <br>
+ <br>
+ <input type="button" onClick="addToCart()" value="Add to Cart">
</form>
- <br>
+
+ <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>