summaryrefslogtreecommitdiffstats
path: root/sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-10-23 17:56:20 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-10-23 17:56:20 +0000
commit7d50a1b4ef72ae679ac8ae52b6cda2bde0165e0d (patch)
tree8bf24b4d18b5be67770f535b3191d4f571a99b82 /sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src
parent9136d6cec1c3d968128c516d1af6a3f79df978b9 (diff)
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
Diffstat (limited to 'sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src')
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Catalog.java27
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverter.java29
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/CurrencyConverterImpl.java38
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/Item.java51
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/java/services/VegetablesCatalogImpl.java52
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/resources/catalog.composite43
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/META-INF/sca-contribution-generated.xml23
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/geronimo-web.xml50
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/WEB-INF/web.xml36
-rw-r--r--sandbox/sca-cloud-tutorial/store-catalog-ibmcloud-2x-webapp/src/main/webapp/index.html14
10 files changed, 363 insertions, 0 deletions
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<Item> catalog = new ArrayList<Item>();
+
+ @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 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:store="http://store"
+ targetNamespace="http://store"
+ name="catalog">
+
+ <component name="Catalog">
+ <implementation.java class="services.VegetablesCatalogImpl"/>
+ <property name="currencyCode">USD</property>
+ <service name="Catalog">
+ <interface.java interface="services.Catalog"/>
+ <tuscany:binding.jsonrpc uri="http://localhost:8080/store-catalog-ibmcloud-2x-webapp/Catalog"/>
+ </service>
+ <reference name="currencyConverter" target="CurrencyConverter"/>
+ </component>
+
+ <component name="CurrencyConverter">
+ <implementation.java class="services.CurrencyConverterImpl"/>
+ <service name="CurrencyConverter">
+ <interface.java interface="services.CurrencyConverter"/>
+ </service>
+ </component>
+
+</composite>
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 @@
+<?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.
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:store="http://store">
+ <deployable composite="store:catalog"/>
+</contribution> \ 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 @@
+<?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.
+-->
+<web:web-app
+ xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0"
+ xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"
+ xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"
+ xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"
+ xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-2.0"
+ xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
+ xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2"
+ xmlns:pers="http://java.sun.com/xml/ns/persistence"
+ xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1"
+ xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"
+ xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
+ <dep:environment>
+ <dep:moduleId>
+ <dep:groupId>org.apache.tuscany</dep:groupId>
+ <dep:artifactId>store-catalog-ibmcloud-2x-webapp</dep:artifactId>
+ <dep:version>1.0</dep:version>
+ <dep:type>car</dep:type>
+ </dep:moduleId>
+
+ <!-- TUSCANY-2622 -->
+ <dep:hidden-classes>
+ <dep:filter>org.apache.axiom</dep:filter>
+ <dep:filter>org.apache.axis2</dep:filter>
+ <dep:filter>org.apache.commons</dep:filter>
+ <dep:filter>org.jdom</dep:filter>
+ </dep:hidden-classes>
+
+ </dep:environment>
+ <web:context-root>/store-catalog-ibmcloud-2x-webapp</web:context-root>
+</web:web-app>
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 @@
+<?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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+ <display-name>store-catalog-ibmcloud-2x-webapp</display-name>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+</web-app> \ 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 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Tuscany Store Scenario - IBM Cloud</title>
+</head>
+<body>
+
+<h2>Tuscany Store Catalog Service</h2>
+</br>
+</br>
+Catalog Service Definition available at : <a href="Catalog?smd">JSON-RPC SMD</a>
+</body>
+</html> \ No newline at end of file