tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r829149 - in /tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp: ./ .settings/ src/ src/services/ war/ war/WEB-INF/
Date Fri, 23 Oct 2009 17:56:02 GMT
Author: lresende
Date: Fri Oct 23 17:56:00 2009
New Revision: 829149

URL: http://svn.apache.org/viewvc?rev=829149&view=rev
Log:
Updating store with new vegetables catalog and adding basic support for shoppingCart services
using JSON-RPC

Added:
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java   (with
props)
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java
  (with props)
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java   (with
props)
Modified:
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml
    tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.classpath Fri Oct 23 17:56:00
2009
@@ -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>
-

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.project Fri Oct 23 17:56:00
2009
@@ -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>

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs
(original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/.settings/com.google.appengine.eclipse.core.prefs
Fri Oct 23 17:56:00 2009
@@ -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=

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/pom.xml Fri Oct 23 17:56:00
2009
@@ -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>

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/log4j.properties Fri Oct
23 17:56:00 2009
@@ -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

Added: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java?rev=829149&view=auto
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java (added)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java Fri Oct
23 17:56:00 2009
@@ -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> {
+
+}

Propchange: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Cart.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Catalog.java Fri
Oct 23 17:56:00 2009
@@ -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;

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java
(original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CatalogAggregatorImpl.java
Fri Oct 23 17:56:00 2009
@@ -36,19 +36,29 @@
 
     @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;
     }

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java
(original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverter.java
Fri Oct 23 17:56:00 2009
@@ -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;

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java
(original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/CurrencyConverterImpl.java
Fri Oct 23 17:56:00 2009
@@ -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;

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Item.java Fri Oct
23 17:56:00 2009
@@ -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;

Added: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java?rev=829149&view=auto
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java
(added)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java
Fri Oct 23 17:56:00 2009
@@ -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);
+    }
+}

Propchange: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/ShoppingCartImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java?rev=829149&view=auto
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java (added)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java Fri
Oct 23 17:56:00 2009
@@ -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();
+
+}

Propchange: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/services/Total.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/src/store.composite Fri Oct
23 17:56:00 2009
@@ -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>

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
(original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
Fri Oct 23 17:56:00 2009
@@ -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>

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
(original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
Fri Oct 23 17:56:00 2009
@@ -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
 

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml Fri Oct
23 17:56:00 2009
@@ -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">

Modified: tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
URL: http://svn.apache.org/viewvc/tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html?rev=829149&r1=829148&r2=829149&view=diff
==============================================================================
--- tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html (original)
+++ tuscany/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html Fri Oct 23 17:56:00
2009
@@ -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>



Mime
View raw message