From 7d50a1b4ef72ae679ac8ae52b6cda2bde0165e0d Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 23 Oct 2009 17:56:20 +0000 Subject: Store vegetable catalog tweaked to run on the ibmcloud environment git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@829153 13f79535-47bb-0310-9956-ffa450edef68 --- .../store-catalog-ibmcloud-2x-webapp/README | 28 ++ .../store-catalog-ibmcloud-2x-webapp/pom.xml | 100 +++++++ .../src/main/java/services/Catalog.java | 27 ++ .../src/main/java/services/CurrencyConverter.java | 29 ++ .../main/java/services/CurrencyConverterImpl.java | 38 +++ .../src/main/java/services/Item.java | 51 ++++ .../main/java/services/VegetablesCatalogImpl.java | 52 ++++ .../src/main/resources/catalog.composite | 43 +++ .../webapp/META-INF/sca-contribution-generated.xml | 23 ++ .../src/main/webapp/WEB-INF/geronimo-web.xml | 50 ++++ .../src/main/webapp/WEB-INF/web.xml | 36 +++ .../src/main/webapp/index.html | 14 + .../store-catalog-ibmcloud-2x-webapp/store.png | Bin 0 -> 15670 bytes .../store-catalog-ibmcloud-2x-webapp/store.svg | 304 +++++++++++++++++++++ 14 files changed, 795 insertions(+) create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/README create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/pom.xml create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Catalog.java create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverter.java create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverterImpl.java create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Item.java create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/VegetablesCatalogImpl.java create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/resources/catalog.composite create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/META-INF/sca-contribution-generated.xml create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/index.html create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/store.png create mode 100644 sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/store.svg diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/README b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/README new file mode 100644 index 0000000000..46e71bf51e --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/README @@ -0,0 +1,28 @@ +Store Sample +====================================== + +This is a sample store scenario that is used as a getting started guide +for Tuscany SCA. For detailed information, please see: + +http://tuscany.apache.org/getting-started-with-tuscany.html + +or + +http://tuscany.apache.org/getting-started-with-tuscany-using-tuscany-eclipse-plugin.html + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as follows: + +cd store +ant compile + +and then, to run: + +ant run + +Once the store application is running use your browser to visit the following +URL: + +http://localhost:8080/store/ diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/pom.xml b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/pom.xml new file mode 100644 index 0000000000..7da92d1df5 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/pom.xml @@ -0,0 +1,100 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-SNAPSHOT + ../pom.xml + + store-catalog-ibmcloud-2x-webapp + war + Apache Tuscany SCA Store Catalog as WebApp + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-webapp + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 2.0-SNAPSHOT + runtime + + + + + + + + ${artifactId} + + + diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Catalog.java b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Catalog.java new file mode 100644 index 0000000000..b5e504fe11 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Catalog.java @@ -0,0 +1,27 @@ +/* + * 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 Catalog { + Item[] get(); +} diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverter.java b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverter.java new file mode 100644 index 0000000000..a064f3dd69 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverter.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 CurrencyConverter { + public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount); + + public String getCurrencySymbol(String currencyCode); +} diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverterImpl.java b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..c354aed447 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverterImpl.java @@ -0,0 +1,38 @@ +/* + * 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; + +public class CurrencyConverterImpl implements CurrencyConverter { + public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) { + if (toCurrencyCode.equals("USD")) + return amount; + else if (toCurrencyCode.equals("EUR")) + return ((double)Math.round(amount * 0.7256 * 100)) /100; + return 0; + } + + public String getCurrencySymbol(String currencyCode) { + if (currencyCode.equals("USD")) + return "$"; + else if (currencyCode.equals("EUR")) + return "E"; //"€"; + return "?"; + } +} diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Item.java b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Item.java new file mode 100644 index 0000000000..27abd4f016 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Item.java @@ -0,0 +1,51 @@ +/* + * 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; + + +public class Item { + private String name; + private String price; + + public Item() { + } + + public Item(String name, String price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + +} diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/VegetablesCatalogImpl.java b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/VegetablesCatalogImpl.java new file mode 100644 index 0000000000..1f22166272 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/VegetablesCatalogImpl.java @@ -0,0 +1,52 @@ +/* + * 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; + +public class VegetablesCatalogImpl implements Catalog { + + @Property + public String currencyCode = "USD"; + + @Reference + public CurrencyConverter currencyConverter; + + private List catalog = new ArrayList(); + + @Init + public void init() { + String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode); + catalog.add(new Item("Broccoli", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99))); + catalog.add(new Item("Aspargus", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55))); + catalog.add(new Item("Cauliflower", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55))); + } + + public Item[] get() { + Item[] catalogArray = new Item[catalog.size()]; + catalog.toArray(catalogArray); + return catalogArray; + } +} diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/resources/catalog.composite b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/resources/catalog.composite new file mode 100644 index 0000000000..b7cb37971f --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/resources/catalog.composite @@ -0,0 +1,43 @@ + + + + + + + USD + + + + + + + + + + + + + + + diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/META-INF/sca-contribution-generated.xml b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/META-INF/sca-contribution-generated.xml new file mode 100644 index 0000000000..c50a04722a --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/META-INF/sca-contribution-generated.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..25d42aac24 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,50 @@ + + + + + + org.apache.tuscany + store-catalog-ibmcloud-2x-webapp + 1.0 + car + + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + + /store-catalog-ibmcloud-2x-webapp + diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/web.xml b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..266c70089a --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,36 @@ + + + + store-catalog-ibmcloud-2x-webapp + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + index.html + + \ No newline at end of file diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/index.html b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/index.html new file mode 100644 index 0000000000..c431aca044 --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/index.html @@ -0,0 +1,14 @@ + + + + +Tuscany Store Scenario - IBM Cloud + + + +

Tuscany Store Catalog Service

+
+
+Catalog Service Definition available at : JSON-RPC SMD + + \ No newline at end of file diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/store.png b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/store.png new file mode 100644 index 0000000000..da413edeee Binary files /dev/null and b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/store.png differ diff --git a/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/store.svg b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/store.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/store.svg @@ -0,0 +1,304 @@ + + + + + + + + + + image/svg+xml + + + + + + + + store + ufs + + ShoppingCart + + CurrencyConverter + + + + + + + + + + CurrenyCode HTTP JSONRPC Atom + + Catalog + + + + -- cgit v1.2.3