You are viewing a plain text version of this content. The canonical link for it is here.
Posted to nuvem-commits@incubator.apache.org by js...@apache.org on 2010/09/21 18:38:12 UTC
svn commit: r999529 - in /incubator/nuvem/trunk/store-standalone/src:
main/java/services/CatalogImpl.java
main/java/services/FruitsCatalogImpl.java main/resources/store.composite
test/java/store/StoreTestCase.java
Author: jsdelfino
Date: Tue Sep 21 18:38:12 2010
New Revision: 999529
URL: http://svn.apache.org/viewvc?rev=999529&view=rev
Log:
Add a local Catalog component. Change list of fruits to help distinguish the different catalogs.
Added:
incubator/nuvem/trunk/store-standalone/src/main/java/services/CatalogImpl.java
- copied, changed from r999519, incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java
Modified:
incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java
incubator/nuvem/trunk/store-standalone/src/main/resources/store.composite
incubator/nuvem/trunk/store-standalone/src/test/java/store/StoreTestCase.java
Copied: incubator/nuvem/trunk/store-standalone/src/main/java/services/CatalogImpl.java (from r999519, incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java)
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/store-standalone/src/main/java/services/CatalogImpl.java?p2=incubator/nuvem/trunk/store-standalone/src/main/java/services/CatalogImpl.java&p1=incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java&r1=999519&r2=999529&rev=999529&view=diff
==============================================================================
--- incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java (original)
+++ incubator/nuvem/trunk/store-standalone/src/main/java/services/CatalogImpl.java Tue Sep 21 18:38:12 2010
@@ -22,18 +22,18 @@ package services;
import org.oasisopen.sca.annotation.Property;
import org.oasisopen.sca.annotation.Reference;
-public class FruitsCatalogImpl implements Catalog {
+public class CatalogImpl implements Catalog {
@Property
public String currencyCode = "USD";
@Reference
- public Catalog remoteCatalog;
+ public Catalog catalog;
@Reference
public CurrencyConverter currencyConverter;
public Item[] items() {
- return remoteCatalog.items();
+ return catalog.items();
}
}
Modified: incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java?rev=999529&r1=999528&r2=999529&view=diff
==============================================================================
--- incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java (original)
+++ incubator/nuvem/trunk/store-standalone/src/main/java/services/FruitsCatalogImpl.java Tue Sep 21 18:38:12 2010
@@ -1,39 +1,36 @@
-/*
- * 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.List;
+
+import org.oasisopen.sca.annotation.Init;
import org.oasisopen.sca.annotation.Property;
import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+@Service(Catalog.class)
+@Scope("COMPOSITE")
public class FruitsCatalogImpl implements Catalog {
-
@Property
public String currencyCode = "USD";
-
- @Reference
- public Catalog remoteCatalog;
-
+
@Reference
public CurrencyConverter currencyConverter;
+ private List<Item> catalog = new ArrayList<Item>();
+
+ @Init
+ public void init() {
+ String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
+ catalog.add(new Item("Acai", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 2.99)));
+ catalog.add(new Item("Carambola", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 3.55)));
+ catalog.add(new Item("Cashew", currencyCode, currencySymbol, currencyConverter.getConversion("USD", currencyCode, 1.55)));
+ }
+
public Item[] items() {
- return remoteCatalog.items();
+ Item[] catalogArray = new Item[catalog.size()];
+ catalog.toArray(catalogArray);
+ return catalogArray;
}
}
Modified: incubator/nuvem/trunk/store-standalone/src/main/resources/store.composite
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/store-standalone/src/main/resources/store.composite?rev=999529&r1=999528&r2=999529&view=diff
==============================================================================
--- incubator/nuvem/trunk/store-standalone/src/main/resources/store.composite (original)
+++ incubator/nuvem/trunk/store-standalone/src/main/resources/store.composite Tue Sep 21 18:38:12 2010
@@ -33,15 +33,35 @@
</component>
<component name="Catalog">
- <implementation.java class="services.FruitsCatalogImpl"/>
+ <implementation.java class="services.CatalogImpl"/>
<property name="currencyCode">USD</property>
<service name="Catalog">
<tuscany:binding.jsonrpc uri="/Catalog"/>
</service>
<reference name="currencyConverter" target="CurrencyConverter"/>
- <reference name="remoteCatalog">
- <tuscany:binding.jsonrpc uri="https://sca-store-catalog.appspot.com/catalog"/>
+
+ <reference name="catalog" target="FruitsCatalog"/>
+
+ <!-- Cheat sheet for demo
+ <reference name="catalog" target="FruitsCatalog"/>
+
+ <reference name="catalog">
+ <tuscany:binding.jsonrpc uri="https://sca-store-catalog.appspot.com/catalog"/>
</reference>
+
+ <tuscany:binding.jsonrpc uri="http://tuscany-store.appspot.com/Catalog"/>
+ <tuscany:binding.jsonrpc uri="http://ec2-204-236-142-71.us-west-1.compute.amazonaws.com:8090/catalog"/>
+ <tuscany:binding.jsonrpc uri="http://localhost:8090/catalog"/>
+ -->
+ </component>
+
+ <component name="FruitsCatalog">
+ <implementation.java class="services.FruitsCatalogImpl"/>
+ <property name="currencyCode">USD</property>
+ <service name="Catalog">
+ <interface.java interface="services.Catalog"/>
+ </service>
+ <reference name="currencyConverter" target="CurrencyConverter" />
</component>
<component name="ShoppingCart">
Modified: incubator/nuvem/trunk/store-standalone/src/test/java/store/StoreTestCase.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/store-standalone/src/test/java/store/StoreTestCase.java?rev=999529&r1=999528&r2=999529&view=diff
==============================================================================
--- incubator/nuvem/trunk/store-standalone/src/test/java/store/StoreTestCase.java (original)
+++ incubator/nuvem/trunk/store-standalone/src/test/java/store/StoreTestCase.java Tue Sep 21 18:38:12 2010
@@ -81,7 +81,7 @@ public class StoreTestCase {
public void testShop() {
Shopper shopper = nodeStore.getService(Shopper.class, "StoreClient");
- String total = shopper.shop("Banana", 5);
+ String total = shopper.shop("Carambola", 5);
System.out.println("Total: " + total);
Assert.assertEquals("$17.75", total);
@@ -109,7 +109,7 @@ public class StoreTestCase {
HtmlCheckBoxInput catalogItems = (HtmlCheckBoxInput) form.getInputByName("items");
System.out.println(">>>" + catalogItems.getAttribute("value"));
- Assert.assertEquals("Platano - $2.99", catalogItems.getAttribute("value"));
+ Assert.assertEquals("Acai - $2.99", catalogItems.getAttribute("value"));
webClient.closeAllWindows();
}