From 2691aa6986e852c4dea45a26411335a65538a9be Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 8 Aug 2009 10:03:33 +0000 Subject: Move www-services to sandbox area until the license of the Amazon jars is clarified git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@802332 13f79535-47bb-0310-9956-ffa450edef68 --- .../cart-amazon/amazon/cart/AmazonCart.java | 44 ++ .../cart-amazon/amazon/cart/AmazonCart.wsdl | 451 +++++++++++++++++++++ .../cart-amazon/amazon/cart/AmazonCartImpl.java | 120 ++++++ .../cart-amazon/amazoncart.composite | 33 ++ .../cart-amazon/launch/LaunchAmazonCart.java | 52 +++ .../cart-amazon/pom.xml | 215 ++++++++++ .../cart-amazon/test/AmazonCartTestCase.java | 99 +++++ 7 files changed, 1014 insertions(+) create mode 100644 sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCart.java create mode 100644 sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCart.wsdl create mode 100644 sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCartImpl.java create mode 100644 sandbox/tutorial-store-www-services/cart-amazon/amazoncart.composite create mode 100644 sandbox/tutorial-store-www-services/cart-amazon/launch/LaunchAmazonCart.java create mode 100644 sandbox/tutorial-store-www-services/cart-amazon/pom.xml create mode 100644 sandbox/tutorial-store-www-services/cart-amazon/test/AmazonCartTestCase.java (limited to 'sandbox/tutorial-store-www-services/cart-amazon') diff --git a/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCart.java b/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCart.java new file mode 100644 index 0000000000..6f968bdba3 --- /dev/null +++ b/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCart.java @@ -0,0 +1,44 @@ +/* + * 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 amazon.cart; + +import org.apache.tuscany.sca.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; + +import com.cart.amazon.CartAdd; +import com.cart.amazon.CartAddResponse; +import com.cart.amazon.CartClear; +import com.cart.amazon.CartClearResponse; +import com.cart.amazon.CartCreate; +import com.cart.amazon.CartCreateResponse; +import com.cart.amazon.CartGet; +import com.cart.amazon.CartGetResponse; + +@Remotable +@DataBinding(value="commonj.sdo.DataObject", wrapped=true) +public interface AmazonCart { + + public CartCreateResponse CartCreate(CartCreate cartCreate); + + public CartAddResponse CartAdd(CartAdd cartAdd); + + public CartClearResponse CartClear(CartClear cartClear); + + public CartGetResponse CartGet(CartGet cartGet); +} diff --git a/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCart.wsdl b/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCart.wsdl new file mode 100644 index 0000000000..051c8ad906 --- /dev/null +++ b/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCart.wsdl @@ -0,0 +1,451 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCartImpl.java b/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCartImpl.java new file mode 100644 index 0000000000..66d72c57c4 --- /dev/null +++ b/sandbox/tutorial-store-www-services/cart-amazon/amazon/cart/AmazonCartImpl.java @@ -0,0 +1,120 @@ +/* + * 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 amazon.cart; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.osoa.sca.annotations.Service; + +import com.cart.amazon.AmazonFactory; +import com.cart.amazon.Cart; +import com.cart.amazon.CartAdd; +import com.cart.amazon.CartAddRequest; +import com.cart.amazon.CartAddResponse; +import com.cart.amazon.CartClear; +import com.cart.amazon.CartClearResponse; +import com.cart.amazon.CartCreate; +import com.cart.amazon.CartCreateResponse; +import com.cart.amazon.CartGet; +import com.cart.amazon.CartGetResponse; +import com.cart.amazon.CartItem; +import com.cart.amazon.CartItems; +import com.cart.amazon.Item1; +import com.cart.amazon.Items1; + +@Service(AmazonCart.class) +public class AmazonCartImpl { + + protected Map cartsHash = new HashMap(); + + public CartCreateResponse CartCreate(CartCreate cartCreate) { + + System.out.println("CartServiceID: " + this.toString()); + System.out.println("Entering cartCreate..."); + String userId = cartCreate.getAWSAccessKeyId(); + + Cart cart = getCart(userId); + if (cart != null) { + System.out.println("User " + cartCreate.getAWSAccessKeyId() + + " has already created a cart with ID: " + + cart.getCartId()); + return null; + } + cart = new Cart(); + cart.setCartItems(new CartItems()); + addCart(userId, cart); + + CartCreateResponse response = AmazonFactory.INSTANCE.createCartCreateResponse(); + System.out.println("Exiting cartCreate..."); + return response; + + } + + public CartAddResponse CartAdd(CartAdd cartAdd) { + + String userId = cartAdd.getAWSAccessKeyId(); + + Cart cart = getCart(userId); + if (cart == null) { + System.out.println("User has not associated Cart yet..."); + return null; + } + + List cartAddRequestList = cartAdd.getRequest(); + CartAddRequest car = (CartAddRequest)cartAddRequestList.get(0); + Items1 carItems = car.getItems(); + List itemList = carItems.getItem(); + Item1 item = (Item1)itemList.get(0); //Take only the first one, no iteration for now + System.out.println("item.getASIN: " + item.getASIN()); + System.out.println("item.getQuantity(): " + item.getQuantity()); + CartItems cartItems = cart.getCartItems(); + List cartItemList = cartItems.getCartItem(); + cart.setCartItems(cartItems); + return null; + } + + public CartClearResponse CartClear(CartClear cartClear) { + String userId = cartClear.getAWSAccessKeyId(); + + Cart cart = getCart(userId); + if (cart == null) { + System.out.println("User has not associated Cart yet..."); + return null; + } + + cart.setCartItems(new CartItems()); + return null; + } + + public CartGetResponse CartGet(CartGet cartGet) { + return null; + } + + private Cart getCart(String userId) { + Cart cart = null; + cart = this.cartsHash.get(userId); + return cart; + } + + private void addCart(String userId, Cart cart) { + this.cartsHash.put(userId, cart); + } +} diff --git a/sandbox/tutorial-store-www-services/cart-amazon/amazoncart.composite b/sandbox/tutorial-store-www-services/cart-amazon/amazoncart.composite new file mode 100644 index 0000000000..6f8cc7b878 --- /dev/null +++ b/sandbox/tutorial-store-www-services/cart-amazon/amazoncart.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/tutorial-store-www-services/cart-amazon/launch/LaunchAmazonCart.java b/sandbox/tutorial-store-www-services/cart-amazon/launch/LaunchAmazonCart.java new file mode 100644 index 0000000000..69dd06c2ef --- /dev/null +++ b/sandbox/tutorial-store-www-services/cart-amazon/launch/LaunchAmazonCart.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 launch; + +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.util.SCAContributionUtil; + +public class LaunchAmazonCart { + + public static void main(String[] args) throws Exception { + + System.out.println("Starting ..."); + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + SCANode node = nodeFactory.createSCANode(null, "http://localhost:9999"); + + URL contribution = SCAContributionUtil.findContributionFromClass(LaunchAmazonCart.class); + node.addContribution("http://amazonCart", contribution); + + node.addToDomainLevelComposite(new QName("http://amazonCart", "amazonCart")); + node.start(); + + System.out.println("amazoncart.composite ready for big business !!!"); + System.in.read(); + + System.out.println("Stopping ..."); + node.stop(); + node.destroy(); + System.out.println(); + } + +} diff --git a/sandbox/tutorial-store-www-services/cart-amazon/pom.xml b/sandbox/tutorial-store-www-services/cart-amazon/pom.xml new file mode 100644 index 0000000000..739ed249d0 --- /dev/null +++ b/sandbox/tutorial-store-www-services/cart-amazon/pom.xml @@ -0,0 +1,215 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-tutorial-store + 1.6-SNAPSHOT + ../pom.xml + + tutorial-cart-amazon + Apache Tuscany SCA Store Tutorial Amazon Cart + + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.1-incubating + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1-incubating + + + + org.apache.tuscany.sca + tuscany-databinding + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.2 + compile + + + + + + ${artifactId} + ${basedir} + ${basedir}/test + + + ${basedir} + + **/*.java + pom.xml + build.xml + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-test-source + generate-sources + + add-source + + + + target/sdo-source + target/wsdl2java-source + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.1-incubating + + + + ${basedir}/amazon/cart/AmazonCart.wsdl + true + true + true + true + + + generate + + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6-SNAPSHOT + + + + generate + + + + + + org.apache.tuscany.sca + tuscany-maven-wsdl2java + 1.6-SNAPSHOT + + + + ${basedir}/amazon/cart/AmazonCart.wsdl + amazon.cart.api + + + generate + + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6-SNAPSHOT + + + + launch.LaunchAmazonCart + + + generate + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + ant + ant-trax + 1.6.5 + + + + + + + + diff --git a/sandbox/tutorial-store-www-services/cart-amazon/test/AmazonCartTestCase.java b/sandbox/tutorial-store-www-services/cart-amazon/test/AmazonCartTestCase.java new file mode 100644 index 0000000000..ede97f7868 --- /dev/null +++ b/sandbox/tutorial-store-www-services/cart-amazon/test/AmazonCartTestCase.java @@ -0,0 +1,99 @@ +/* + * 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 test; + +import java.net.URL; + +import javax.xml.namespace.QName; + +import launch.LaunchAmazonCart; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.util.SCAContributionUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import amazon.cart.AmazonCart; + +import com.cart.amazon.AmazonFactory; +import com.cart.amazon.CartCreate; +import commonj.sdo.DataObject; + +/** + * Test case for helloworld web service client + */ +public class AmazonCartTestCase { + + private SCANode node; + private AmazonCart amazonCart; + + @Before + public void startClient() throws Exception { + try { + + System.out.println("Starting ..."); + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + node = nodeFactory.createSCANode(null, null); + + URL contribution = SCAContributionUtil.findContributionFromClass(LaunchAmazonCart.class); + node.addContribution("http://amazonCart", contribution); + + node.addToDomainLevelComposite(new QName("http://amazonCart", "amazonCart")); + node.start(); + + System.out.println("amazoncart.composite ready for big business !!!"); + + amazonCart = node.getDomain().getService(AmazonCart.class, "AmazonCartServiceComponent"); + + } catch (Throwable e) { + e.printStackTrace(); + } + } + + @Test + public void testCartCreate() throws Exception { + System.out.println("Entering test..."); + CartCreate create = AmazonFactory.INSTANCE.createCartCreate(); + DataObject root = amazonCart.CartCreate(create); + // Assert.assertEquals("Hello Smith", msg); + System.out.println("Exiting test..."); + } + + /* + * @Test public void testEmbeddedReferenceClient() throws Exception { String + * msg = helloTuscanyService.getGreetings("Tuscany"); + * Assert.assertEquals("Hello Tuscany", msg); } + */ + + @After + public void stopClient() throws Exception { + System.out.println("Stopping ..."); + node.stop(); + node.destroy(); + System.out.println(); + } + + /* + * public void testCartCreate() throws Exception { DataObject root = + * amazonCart.cartCreate(null); //assertNotNull(root); + * //assertEquals("Luciano Resende", root.getString("CUSTOMER[1]/NAME")); } + */ +} -- cgit v1.2.3