From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../store-client/META-INF/sca-contribution.xml | 23 ++++ java/sca/tutorial/store-client/client/Shopper.java | 29 +++++ .../tutorial/store-client/client/ShopperImpl.java | 63 +++++++++++ .../store-client/launch/LaunchStoreClientNode.java | 43 +++++++ java/sca/tutorial/store-client/pom.xml | 123 +++++++++++++++++++++ java/sca/tutorial/store-client/services/Cart.java | 28 +++++ .../tutorial/store-client/services/Catalog.java | 27 +++++ java/sca/tutorial/store-client/services/Item.java | 66 +++++++++++ java/sca/tutorial/store-client/services/Total.java | 29 +++++ .../tutorial/store-client/store-client.composite | 38 +++++++ 10 files changed, 469 insertions(+) create mode 100644 java/sca/tutorial/store-client/META-INF/sca-contribution.xml create mode 100644 java/sca/tutorial/store-client/client/Shopper.java create mode 100644 java/sca/tutorial/store-client/client/ShopperImpl.java create mode 100644 java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java create mode 100644 java/sca/tutorial/store-client/pom.xml create mode 100644 java/sca/tutorial/store-client/services/Cart.java create mode 100644 java/sca/tutorial/store-client/services/Catalog.java create mode 100644 java/sca/tutorial/store-client/services/Item.java create mode 100644 java/sca/tutorial/store-client/services/Total.java create mode 100644 java/sca/tutorial/store-client/store-client.composite (limited to 'java/sca/tutorial/store-client') diff --git a/java/sca/tutorial/store-client/META-INF/sca-contribution.xml b/java/sca/tutorial/store-client/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..30ffa61ed2 --- /dev/null +++ b/java/sca/tutorial/store-client/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/java/sca/tutorial/store-client/client/Shopper.java b/java/sca/tutorial/store-client/client/Shopper.java new file mode 100644 index 0000000000..f8643d4c52 --- /dev/null +++ b/java/sca/tutorial/store-client/client/Shopper.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 client; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Shopper { + + String shop(String itemName, int quantity); + +} diff --git a/java/sca/tutorial/store-client/client/ShopperImpl.java b/java/sca/tutorial/store-client/client/ShopperImpl.java new file mode 100644 index 0000000000..c017548fb3 --- /dev/null +++ b/java/sca/tutorial/store-client/client/ShopperImpl.java @@ -0,0 +1,63 @@ +/* + * 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 client; + +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.annotations.Reference; + +import services.Cart; +import services.Catalog; +import services.Item; +import services.Total; + +public class ShopperImpl implements Shopper { + + @Reference + public Catalog catalog; + + @Reference + public Cart shoppingCart; + + @Reference + public Total shoppingTotal; + + public String shop(String itemName, int quantity) { + + Item[] items = catalog.get(); + for (Item item: items) { + if (item.getName().startsWith(itemName)) { + + try { + shoppingCart.delete(""); + } catch (NotFoundException e) { + } + + for (int i = 0; i < quantity; i++) { + shoppingCart.post("item" + i, item); + } + + return shoppingTotal.getTotal(); + } + } + + return ""; + } + +} diff --git a/java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java b/java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java new file mode 100644 index 0000000000..4709240db5 --- /dev/null +++ b/java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java @@ -0,0 +1,43 @@ +/* + * 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.SCAClient; +import org.apache.tuscany.sca.node.SCANode2; +import org.apache.tuscany.sca.node.launcher.NodeLauncher; + +import client.Shopper; + +public class LaunchStoreClientNode { + + public static void main(String[] args) throws Exception { + NodeLauncher nodeLauncher = NodeLauncher.newInstance(); + SCANode2 storeClientNode = nodeLauncher.createNode("http://localhost:9990/node-config/StoreClientNode"); + storeClientNode.start(); + SCAClient client = (SCAClient)storeClientNode; + + Shopper shopper = client.getService(Shopper.class, "StoreClient"); + + String total = shopper.shop("Orange", 5); + System.out.println("Total: " + total); + + storeClientNode.stop(); + } +} diff --git a/java/sca/tutorial/store-client/pom.xml b/java/sca/tutorial/store-client/pom.xml new file mode 100644 index 0000000000..0e180fce00 --- /dev/null +++ b/java/sca/tutorial/store-client/pom.xml @@ -0,0 +1,123 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-tutorial + 1.4-SNAPSHOT + ../pom.xml + + tutorial-store-client + Apache Tuscany SCA Tutorial Online Store Client + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node2-launcher + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node2-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + + ${artifactId} + ${basedir} + + + ${basedir} + + **/*.java + **/.*/** + pom.xml + build.xml + target/** + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + + diff --git a/java/sca/tutorial/store-client/services/Cart.java b/java/sca/tutorial/store-client/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/java/sca/tutorial/store-client/services/Cart.java @@ -0,0 +1,28 @@ +/* + * 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.osoa.sca.annotations.Remotable; + +@Remotable +public interface Cart extends Collection { + +} diff --git a/java/sca/tutorial/store-client/services/Catalog.java b/java/sca/tutorial/store-client/services/Catalog.java new file mode 100644 index 0000000000..2c3b19f579 --- /dev/null +++ b/java/sca/tutorial/store-client/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.osoa.sca.annotations.Remotable; + +@Remotable +public interface Catalog { + Item[] get(); +} diff --git a/java/sca/tutorial/store-client/services/Item.java b/java/sca/tutorial/store-client/services/Item.java new file mode 100644 index 0000000000..81cefcdbef --- /dev/null +++ b/java/sca/tutorial/store-client/services/Item.java @@ -0,0 +1,66 @@ +/* + * 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; + private String origin; + + public Item() { + } + + public Item(String name, String price, String origin) { + this.name = name; + this.price = price; + this.origin = origin; + } + + 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; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } + +} diff --git a/java/sca/tutorial/store-client/services/Total.java b/java/sca/tutorial/store-client/services/Total.java new file mode 100644 index 0000000000..8f464e526f --- /dev/null +++ b/java/sca/tutorial/store-client/services/Total.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.osoa.sca.annotations.Remotable; + +@Remotable +public interface Total { + + String getTotal(); + +} diff --git a/java/sca/tutorial/store-client/store-client.composite b/java/sca/tutorial/store-client/store-client.composite new file mode 100644 index 0000000000..3c5f1637ef --- /dev/null +++ b/java/sca/tutorial/store-client/store-client.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + -- cgit v1.2.3