summaryrefslogtreecommitdiffstats
path: root/java/sca/samples/store/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/samples/store/src/main/java')
-rw-r--r--java/sca/samples/store/src/main/java/launch/Launch.java40
-rw-r--r--java/sca/samples/store/src/main/java/services/Cart.java28
-rw-r--r--java/sca/samples/store/src/main/java/services/Catalog.java27
-rw-r--r--java/sca/samples/store/src/main/java/services/CurrencyConverter.java29
-rw-r--r--java/sca/samples/store/src/main/java/services/CurrencyConverterImpl.java38
-rw-r--r--java/sca/samples/store/src/main/java/services/FruitsCatalogImpl.java52
-rw-r--r--java/sca/samples/store/src/main/java/services/Item.java50
-rw-r--r--java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java112
-rw-r--r--java/sca/samples/store/src/main/java/services/Total.java29
9 files changed, 0 insertions, 405 deletions
diff --git a/java/sca/samples/store/src/main/java/launch/Launch.java b/java/sca/samples/store/src/main/java/launch/Launch.java
deleted file mode 100644
index 06981d17eb..0000000000
--- a/java/sca/samples/store/src/main/java/launch/Launch.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-import org.apache.tuscany.sca.node.Contribution;
-import org.apache.tuscany.sca.node.ContributionLocationHelper;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
-
-public class Launch {
- public static void main(String[] args) throws Exception {
- System.out.println("Starting ...");
- String contribution = ContributionLocationHelper.getContributionLocation(Launch.class);
- Node node = NodeFactory.newInstance().createNode("store.composite", new Contribution("test", contribution));
- node.start();
- System.out.println("store.composite ready for big business !!!");
- System.in.read();
- System.out.println("Stopping ...");
- node.stop();
- node.destroy();
- System.out.println();
- }
-}
diff --git a/java/sca/samples/store/src/main/java/services/Cart.java b/java/sca/samples/store/src/main/java/services/Cart.java
deleted file mode 100644
index 3fb5439bc3..0000000000
--- a/java/sca/samples/store/src/main/java/services/Cart.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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> {
-
-}
diff --git a/java/sca/samples/store/src/main/java/services/Catalog.java b/java/sca/samples/store/src/main/java/services/Catalog.java
deleted file mode 100644
index b5e504fe11..0000000000
--- a/java/sca/samples/store/src/main/java/services/Catalog.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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/java/sca/samples/store/src/main/java/services/CurrencyConverter.java b/java/sca/samples/store/src/main/java/services/CurrencyConverter.java
deleted file mode 100644
index a064f3dd69..0000000000
--- a/java/sca/samples/store/src/main/java/services/CurrencyConverter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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/java/sca/samples/store/src/main/java/services/CurrencyConverterImpl.java b/java/sca/samples/store/src/main/java/services/CurrencyConverterImpl.java
deleted file mode 100644
index c354aed447..0000000000
--- a/java/sca/samples/store/src/main/java/services/CurrencyConverterImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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/java/sca/samples/store/src/main/java/services/FruitsCatalogImpl.java b/java/sca/samples/store/src/main/java/services/FruitsCatalogImpl.java
deleted file mode 100644
index d132a24b00..0000000000
--- a/java/sca/samples/store/src/main/java/services/FruitsCatalogImpl.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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 FruitsCatalogImpl 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("Apple", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99)));
- catalog.add(new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55)));
- catalog.add(new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55)));
- }
-
- public Item[] get() {
- Item[] catalogArray = new Item[catalog.size()];
- catalog.toArray(catalogArray);
- return catalogArray;
- }
-}
diff --git a/java/sca/samples/store/src/main/java/services/Item.java b/java/sca/samples/store/src/main/java/services/Item.java
deleted file mode 100644
index fe32cfc828..0000000000
--- a/java/sca/samples/store/src/main/java/services/Item.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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/java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java b/java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java
deleted file mode 100644
index 698614212d..0000000000
--- a/java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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 ="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);
- }
-}
diff --git a/java/sca/samples/store/src/main/java/services/Total.java b/java/sca/samples/store/src/main/java/services/Total.java
deleted file mode 100644
index b77cc1c7ac..0000000000
--- a/java/sca/samples/store/src/main/java/services/Total.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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();
-
-}