diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /java/sca/tutorial/store-client |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/tutorial/store-client')
-rw-r--r-- | java/sca/tutorial/store-client/META-INF/sca-contribution.xml | 23 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/client/Shopper.java | 29 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/client/ShopperImpl.java | 63 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/launch/LaunchStoreClientNode.java | 43 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/pom.xml | 123 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/services/Cart.java | 28 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/services/Catalog.java | 27 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/services/Item.java | 66 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/services/Total.java | 29 | ||||
-rw-r--r-- | java/sca/tutorial/store-client/store-client.composite | 38 |
10 files changed, 469 insertions, 0 deletions
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 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:s="http://store"> + <deployable composite="s:store-client"/> +</contribution>
\ 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 @@ +<?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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-tutorial</artifactId> + <version>1.4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tutorial-store-client</artifactId> + <name>Apache Tuscany SCA Tutorial Online Store Client</name> + + <repositories> + <repository> + <id>apache.incubator</id> + <url>http://people.apache.org/repo/m2-incubating-repository</url> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-data-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node2-launcher</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node2-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-node-runtime</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-atom-abdera</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>1.4-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <sourceDirectory>${basedir}</sourceDirectory> + <resources> + <resource> + <directory>${basedir}</directory> + <excludes> + <exclude>**/*.java</exclude> + <exclude>**/.*/**</exclude> + <exclude>pom.xml</exclude> + <exclude>build.xml</exclude> + <exclude>target/**</exclude> + </excludes> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-maven-ant-generator</artifactId> + <version>1.4-SNAPSHOT</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> 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<String, Item> { + +} 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 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://store" + name="store-client"> + + <component name="StoreClient"> + <implementation.java class="client.ShopperImpl"/> + <reference name="catalog" target="StoreSupplierCatalog"> + <binding.ws/> + </reference> + <reference name="shoppingCart" target="StoreSupplierShoppingCart/Cart"> + <t:binding.atom/> + </reference> + <reference name="shoppingTotal" target="StoreSupplierShoppingCart/Total"> + <binding.ws/> + </reference> + </component> + +</composite> |