You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/10/27 22:10:29 UTC

svn commit: r589202 - in /incubator/tuscany/java/sca/tutorial: assets/services/ assets/services/merged/ cloud/launch/ cloud/launch/cloud/ store-eu/ store-eu/launch/ store-eu/uiservices/ store/ store/launch/ store/launch/merged/ store/launch/store/

Author: jsdelfino
Date: Sat Oct 27 13:10:28 2007
New Revision: 589202

URL: http://svn.apache.org/viewvc?rev=589202&view=rev
Log:
Minor fixes, refactored some of the launchers. Round the item prices. Added a separate composite for the merged store.

Added:
    incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/
    incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java
      - copied, changed from r589154, incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java
    incubator/tuscany/java/sca/tutorial/store/launch/merged/
    incubator/tuscany/java/sca/tutorial/store/launch/merged/LaunchMergedStore.java   (with props)
    incubator/tuscany/java/sca/tutorial/store/launch/store/
    incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java
      - copied, changed from r589154, incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java
    incubator/tuscany/java/sca/tutorial/store/store-merged.composite   (with props)
Removed:
    incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java
    incubator/tuscany/java/sca/tutorial/store-eu/launch/LaunchEUStore.java
    incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java
Modified:
    incubator/tuscany/java/sca/tutorial/assets/services/CurrencyConverterImpl.java
    incubator/tuscany/java/sca/tutorial/assets/services/ShoppingCartImpl.java
    incubator/tuscany/java/sca/tutorial/assets/services/merged/MergedCatalogImpl.java
    incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite
    incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html
    incubator/tuscany/java/sca/tutorial/store/store.composite

Modified: incubator/tuscany/java/sca/tutorial/assets/services/CurrencyConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/assets/services/CurrencyConverterImpl.java?rev=589202&r1=589201&r2=589202&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/assets/services/CurrencyConverterImpl.java (original)
+++ incubator/tuscany/java/sca/tutorial/assets/services/CurrencyConverterImpl.java Sat Oct 27 13:10:28 2007
@@ -24,7 +24,7 @@
         if (toCurrencyCode.equals("USD"))
             return amount;
         else if (toCurrencyCode.equals("EUR"))
-            return amount * 0.7256;
+            return ((double)Math.round(amount * 0.7256 * 100)) /100;
         return 0;
     }
 
@@ -32,7 +32,7 @@
         if (currencyCode.equals("USD"))
             return "$";
         else if (currencyCode.equals("EUR"))
-            return "€";
+            return "E"; //"€";
         return "?";
     }
 }

Modified: incubator/tuscany/java/sca/tutorial/assets/services/ShoppingCartImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/assets/services/ShoppingCartImpl.java?rev=589202&r1=589201&r2=589202&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/assets/services/ShoppingCartImpl.java (original)
+++ incubator/tuscany/java/sca/tutorial/assets/services/ShoppingCartImpl.java Sat Oct 27 13:10:28 2007
@@ -84,7 +84,7 @@
     }
 
     private String getTotal() {
-        float total = 0;
+        double total = 0;
         String currencySymbol = "";
         if (!cart.isEmpty()) {
             String item = ((Content)cart.values().iterator().next().getContents().get(0)).getValue();
@@ -92,7 +92,7 @@
         }
         for (Entry entry : cart.values()) {
             String item = ((Content)entry.getContents().get(0)).getValue();
-            total += Float.valueOf(item.substring(item.indexOf("-") + 3));
+            total += Double.valueOf(item.substring(item.indexOf("-") + 3));
         }
         return currencySymbol + String.valueOf(total);
     }

Modified: incubator/tuscany/java/sca/tutorial/assets/services/merged/MergedCatalogImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/assets/services/merged/MergedCatalogImpl.java?rev=589202&r1=589201&r2=589202&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/assets/services/merged/MergedCatalogImpl.java (original)
+++ incubator/tuscany/java/sca/tutorial/assets/services/merged/MergedCatalogImpl.java Sat Oct 27 13:10:28 2007
@@ -47,16 +47,16 @@
         
         String[] catalog = new String[fruits.length + vegetables.length];
         int i =0;
-        for (String fruit: fruits) {
-            String name = fruit.substring(0, fruit.indexOf('-') - 1);
-            double price = Double.parseDouble(fruit.substring(fruit.indexOf('-') + 3));
+        for (String item: fruits) {
+            String name = item.substring(0, item.indexOf('-') - 1);
+            double price = Double.valueOf(item.substring(item.indexOf("-") + 3));
             price = currencyConverter.getConversion("USD", currencyCode, price);
             catalog[i++] = name + " - " + currencySymbol + price;
         }
         
-        for (String vegetable: vegetables) {
-            String name = vegetable.substring(0, vegetable.indexOf('-') - 1);
-            double price = Double.parseDouble(vegetable.substring(vegetable.indexOf('-') + 3));
+        for (String item: vegetables) {
+            String name = item.substring(0, item.indexOf('-') - 1);
+            double price = Double.valueOf(item.substring(item.indexOf("-") + 3));
             price = currencyConverter.getConversion("USD", currencyCode, price);
             catalog[i++] = name + " - " + currencySymbol + price;
         }

Copied: incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java (from r589154, incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java?p2=incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java&p1=incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java&r1=589154&r2=589202&rev=589202&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/cloud/launch/LaunchCloud.java (original)
+++ incubator/tuscany/java/sca/tutorial/cloud/launch/cloud/LaunchCloud.java Sat Oct 27 13:10:28 2007
@@ -17,7 +17,7 @@
  * under the License.    
  */
 
-package launch;
+package launch.cloud;
 
 import java.net.URL;
 

Modified: incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite?rev=589202&r1=589201&r2=589202&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite (original)
+++ incubator/tuscany/java/sca/tutorial/store-eu/store-eu.composite Sat Oct 27 13:10:28 2007
@@ -38,7 +38,7 @@
     
 	<component name="Catalog">
 		<implementation.java class="services.merged.MergedCatalogImpl"/> 
-		<property name="currencyCode">USD</property>
+		<property name="currencyCode">EUR</property>
 		<service name="Catalog">
 			<t:binding.jsonrpc uri="CatalogJS"/>
 			<binding.ws uri="CatalogWS"/>

Modified: incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html?rev=589202&r1=589201&r2=589202&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html (original)
+++ incubator/tuscany/java/sca/tutorial/store-eu/uiservices/store.html Sat Oct 27 13:10:28 2007
@@ -16,108 +16,104 @@
     * specific language governing permissions and limitations
     * under the License.    
 -->
-<html>
-<head>
-<title>Store</TITLE>
-
-<script type="text/javascript" src="binding-atom.js"></script>
-<script type="text/javascript" src="binding-jsonrpc.js"></script>
-<script language="JavaScript">
-
-	//Reference
-	catalog = (new JSONRpcClient("../CatalogJS")).Catalog;
-	//Reference
-	shoppingCart = new AtomClient("../ShoppingCart");
-
-
-	function catalog_getResponse(items) {
+<html>
+<head>
+<title>Store</TITLE>
+
+<script type="text/javascript" src="binding-atom.js"></script>
+<script type="text/javascript" src="binding-jsonrpc.js"></script>
+<script language="JavaScript">
+
+	//Reference
+	catalog = (new JSONRpcClient("../CatalogJS")).Catalog;
+	//Reference
+	shoppingCart = new AtomClient("../ShoppingCart");
+
+
+	function catalog_getResponse(items) {
 		var catalog = "";
-		//fixme
-		items = items.String_collection.String;
 		for (var i=0; i<items.length; i++) {
-		    //fixme
-		    var item = items[i]["$"];
 			catalog += '<input name="items" type="checkbox" value="' + 
-						item + '">' + item + ' <br>';
+						items[i] + '">' + items[i] + ' <br>';
 		}
 		document.getElementById('catalog').innerHTML=catalog;
-	}
-	
-	function shoppingCart_getResponse(feed) {
-		if (feed != null) {
-			var entries = feed.getElementsByTagName("entry");              
-			var list = "";
-			for (var i=0; i<entries.length; i++) {
-				var item = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue;
+	}
+	
+	function shoppingCart_getResponse(feed) {
+		if (feed != null) {
+			var entries = feed.getElementsByTagName("entry");              
+			var list = "";
+			for (var i=0; i<entries.length; i++) {
+				var item = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue;
 				list += item + ' <br>';
-			}
+			}
 			document.getElementById("shoppingCart").innerHTML = list;
-			document.getElementById('total').innerHTML = feed.getElementsByTagName("subtitle")[0].firstChild.nodeValue;
-		}
-	}
-	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>cart-item</title><content type="text">'+items[i].value+'</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" action="/ui/store.html">'+
-					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 = "";	
-	}	
-
-	catalog.get(catalog_getResponse);
+			document.getElementById('total').innerHTML = feed.getElementsByTagName("subtitle")[0].firstChild.nodeValue;
+		}
+	}
+	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>cart-item</title><content type="text">'+items[i].value+'</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" action="/ui/store.html">'+
+					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 = "";	
+	}	
+
+	catalog.get(catalog_getResponse);
 	shoppingCart.get("", shoppingCart_getResponse);
-</script>
-
-</head>
-
-<body>
-<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>
-  
+</script>
+
+</head>
+
+<body>
+<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">
+   	<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">     
+		<div id="total"></div>
+		<br>		
+		<input type="button" onClick="checkoutCart()" value="Checkout"> 
+		<input type="button" onClick="deleteCart()" value="Empty">     
 	   	<a href="../ShoppingCart/">(feed)</a>
-	</form>    
-  </div>
-</body>
-</html>
+	</form>    
+  </div>
+</body>
+</html>

Added: incubator/tuscany/java/sca/tutorial/store/launch/merged/LaunchMergedStore.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/launch/merged/LaunchMergedStore.java?rev=589202&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/launch/merged/LaunchMergedStore.java (added)
+++ incubator/tuscany/java/sca/tutorial/store/launch/merged/LaunchMergedStore.java Sat Oct 27 13:10:28 2007
@@ -0,0 +1,50 @@
+/*
+ * 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 launch.merged;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.util.SCAContributionUtil;
+
+public class LaunchMergedStore {
+    public static void main(String[] args) throws Exception {
+        System.out.println("Starting ...");
+        SCANodeFactory nodeFactory = SCANodeFactory.newInstance();
+        SCANode node = nodeFactory.createSCANode("http://localhost:8101/store", "http://localhost:9999");
+        
+        URL contribution = SCAContributionUtil.findContributionFromClass(LaunchMergedStore.class);
+        node.addContribution("http://store", contribution);
+        
+        node.addToDomainLevelComposite(new QName("http://store", "store-merged"));
+        node.start();
+
+        System.out.println("store-merged.composite ready for big business !!!");
+        System.in.read();
+        
+        System.out.println("Stopping ...");
+        node.stop();
+        node.destroy();
+        System.out.println();
+    }
+}

Propchange: incubator/tuscany/java/sca/tutorial/store/launch/merged/LaunchMergedStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/tutorial/store/launch/merged/LaunchMergedStore.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java (from r589154, incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java?p2=incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java&p1=incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java&r1=589154&r2=589202&rev=589202&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/launch/LaunchStore.java (original)
+++ incubator/tuscany/java/sca/tutorial/store/launch/store/LaunchStore.java Sat Oct 27 13:10:28 2007
@@ -17,7 +17,7 @@
  * under the License.    
  */
 
-package launch;
+package launch.store;
 
 import java.net.URL;
 

Added: incubator/tuscany/java/sca/tutorial/store/store-merged.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/store-merged.composite?rev=589202&view=auto
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/store-merged.composite (added)
+++ incubator/tuscany/java/sca/tutorial/store/store-merged.composite Sat Oct 27 13:10:28 2007
@@ -0,0 +1,61 @@
+<?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-merged">
+		
+	<component name="ui">
+		<t:implementation.resource location="uiservices"/>
+		<service name="Resource">
+			<t:binding.http/>
+		</service> 	
+	</component>		
+
+	<component name="FruitsCatalog">
+		<implementation.java class="services.FruitsCatalogImpl"/> 
+		<property name="currencyCode">USD</property>
+		<reference name="currencyConverter" target="CurrencyConverter"/>	
+	</component> 
+ 	
+	<component name="Catalog">
+		<implementation.java class="services.merged.MergedCatalogImpl"/> 
+		<property name="currencyCode">USD</property>
+		<service name="Catalog">
+			<t:binding.jsonrpc uri="CatalogJS"/>
+			<binding.ws uri="CatalogWS"/>
+   		</service>
+		<reference name="fruitsCatalog" target="FruitsCatalog"/>	
+		<reference name="vegetablesCatalog" target="CloudVegetablesCatalog"/>	
+		<reference name="currencyConverter" target="CurrencyConverter"/>	
+	</component>
+ 	
+	<component name="ShoppingCart">
+		<implementation.java class="services.ShoppingCartImpl"/>
+		<service name="Collection">
+			<t:binding.atom/>
+		</service>    	
+	</component>
+    
+	<component name="CurrencyConverter">
+		<implementation.java class="services.CurrencyConverterImpl"/>
+	</component>     
+
+</composite>

Propchange: incubator/tuscany/java/sca/tutorial/store/store-merged.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/tutorial/store/store.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/store/store.composite?rev=589202&r1=589201&r2=589202&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/store/store.composite (original)
+++ incubator/tuscany/java/sca/tutorial/store/store.composite Sat Oct 27 13:10:28 2007
@@ -20,7 +20,6 @@
 <composite	xmlns="http://www.osoa.org/xmlns/sca/1.0"
 		xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
 		targetNamespace="http://store"
-		xmlns:s="http://store"
 		name="store">
 		
 	<component name="ui">
@@ -34,7 +33,6 @@
 		<implementation.java class="services.FruitsCatalogImpl"/> 
 		<property name="currencyCode">USD</property>
 		<service name="Catalog">
-			<binding.sca/>
 			<t:binding.jsonrpc uri="CatalogJS"/>
    		</service>
 		<reference name="currencyConverter" target="CurrencyConverter"/>	
@@ -51,18 +49,4 @@
 		<implementation.java class="services.CurrencyConverterImpl"/>
 	</component>     
 
-	<!--
-	<component name="Catalog">
-		<implementation.java class="services.merged.MergedCatalogImpl"/> 
-		<property name="currencyCode">USD</property>
-		<service name="Catalog">
-			<t:binding.jsonrpc uri="CatalogJS"/>
-			<binding.ws uri="CatalogWS"/>
-   		</service>
-		<reference name="fruitsCatalog" target="FruitsCatalog"/>	
-		<reference name="vegetablesCatalog" target="CloudVegetablesCatalog"/>	
-		<reference name="currencyConverter" target="CurrencyConverter"/>	
-	</component>
-	-->
- 	
 </composite>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org