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 --- .../www-services/catalog-amazon/cart-amazon/README | 77 + .../catalog-amazon/cart-amazon/build.xml | 74 + .../cart-amazon/lib/AWS2007_05_14.jar | Bin 0 -> 297809 bytes .../catalog-amazon/cart-amazon/shoppingstore.png | Bin 0 -> 382749 bytes .../shoppingstore/server/ShoppingStoreServer.java | 25 + .../shoppingstore/services/cart/CartService.java | 35 + .../services/cart/CartServiceImpl.java | 144 + .../services/proxy/ShoppingStoreService.java | 30 + .../services/proxy/ShoppingStoreServiceImpl.java | 49 + .../src/main/resources/shoppingstore.composite | 20 + .../src/main/resources/wsdl/shoppingstore.wsdl | 3023 ++++++++++++++++++++ 11 files changed, 3477 insertions(+) create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/README create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/build.xml create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/lib/AWS2007_05_14.jar create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/shoppingstore.png create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/server/ShoppingStoreServer.java create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/cart/CartService.java create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/cart/CartServiceImpl.java create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/proxy/ShoppingStoreService.java create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/proxy/ShoppingStoreServiceImpl.java create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/resources/shoppingstore.composite create mode 100644 sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/resources/wsdl/shoppingstore.wsdl (limited to 'sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon') diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/README b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/README new file mode 100644 index 0000000000..b5322f82c2 --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/README @@ -0,0 +1,77 @@ +Shopping Store Web Service Sample +================================= +This sample creates an shopping store application using Amazon's WS API interface. This sample intents to provide +the same services provided by Amazon but implementing them as SCA components. These services are provided through +a web service interface. + +If you just want to run it to see what happens you need to run the server first. So, open a command prompt, navigate +to the shoppingstore sample directory and do: + +1 - "ant" to compile it +2 - "ant run" to get the server up and running +3 - You should see the following output from the run target: + run: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] ToyApp server started (press enter to shutdown) + +Once the server is running, it will be expecting requests from a client through its Web Service interface. + +The WSDL describing the WS interface can be obtained opening a web broeser pointing to +http://localhost:8080/ShoppingStoreServiceComponent?wsdl + + +Sample Overview +--------------- +Currently, the sample provides two components: + 1 - ShoppingStoreService: that is wired to a reference with a web service binding and plays the role of a proxy service which offers all the operations exposed through the WSDL API and forwards every invocation to the actual service that in fact implements the service invoked. + 2 - CartService: currently, this is the only component offering an actual service through the Shopping Store. It provides the following operations: CartCreate, CartAdd, CartClear, CartGet. + +shoppingstore/ + lib/ + AWS2007_05_14.jar - The jar file containing all the classes generated out of Amazon's WSDL using + the Axis2's wsdl2java utility (the databinding used was jaxb) + src/ + main/ + java/ + shoppingstore/ + server/ + ShoppingStoreServer.java - starts the SCA Runtime and deploys + the shoppingstore.composite. + In doing this, the SCA WSDL binding + acts to expose the ShoppingStoreService + over WS + services/ + cart/ + CartService.java - Java interface description for + CartServiceComponent + CartServiceImpl.java - component implementation + proxy/ + ShoppingStoreService.java - Java interface description for + ShoppingStoreServiceComponent + ShoppingStoreServiceImpl.java - component implementation + resources/ + wsdl/ + shoppingstore.wsdl - the service description that the + SCA reference uses to bind to. This + wsdl file is very similar to Amazon's + WSDL released on May 14th, 2007. Only + two modifications were done: + 1 - Non-implemented services had to be + commented out from the WSDL + 2 - Its location was modified in order + for it to point to this sample's address + shoppingstore.composite - the SCA assembly for this sample + test/ - no test provided so far + shoppingstore.png - a pictorial representation of the + current status of the sample, plus future enhancements + build.xml - the Ant build file + + +Building And Running The Sample Using Ant +----------------------------------------- +Take a look at the beginning of this document. + +Building And Running The Sample Using Maven +------------------------------------------- +No maven support has been implemented yet. \ No newline at end of file diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/build.xml b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/build.xml new file mode 100644 index 0000000000..0a455f52b7 --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/lib/AWS2007_05_14.jar b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/lib/AWS2007_05_14.jar new file mode 100644 index 0000000000..4b5232fd3b Binary files /dev/null and b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/lib/AWS2007_05_14.jar differ diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/shoppingstore.png b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/shoppingstore.png new file mode 100644 index 0000000000..e88abcbd58 Binary files /dev/null and b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/shoppingstore.png differ diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/server/ShoppingStoreServer.java b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/server/ShoppingStoreServer.java new file mode 100644 index 0000000000..486946b2fc --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/server/ShoppingStoreServer.java @@ -0,0 +1,25 @@ +package shoppingstore.server; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class ShoppingStoreServer { + + public static void main(String[] args) { + + SCADomain scaDomain = SCADomain.newInstance("shoppingstore.composite"); + + try { + System.out.println("ToyApp server started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + scaDomain.close(); + System.out.println("ToyApp server stopped"); + } + + +} diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/cart/CartService.java b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/cart/CartService.java new file mode 100644 index 0000000000..e8f383c3e1 --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/cart/CartService.java @@ -0,0 +1,35 @@ +package shoppingstore.services.cart; + +import org.osoa.sca.annotations.Remotable; + +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartAdd; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartAddResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartClear; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartClearResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartCreate; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartCreateResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartGet; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartGetResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartModify; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartModifyResponse; + +@Remotable +public interface CartService { + + public CartCreateResponse CartCreate(CartCreate cartCreate); + + public CartAddResponse CartAdd(CartAdd cartAdd); + + public CartModifyResponse CartModify(CartModify cartModify); + + public CartClearResponse CartClear(CartClear cartClear); + + public CartGetResponse CartGet(CartGet cartGet); + + //@Init + //public void start(); + + //@Destroy + //public void stop(); + +} diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/cart/CartServiceImpl.java b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/cart/CartServiceImpl.java new file mode 100644 index 0000000000..1579dbd60d --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/cart/CartServiceImpl.java @@ -0,0 +1,144 @@ +package shoppingstore.services.cart; + +import java.util.HashMap; + +import org.osoa.sca.annotations.Scope; + +import com.amazon.webservices.awsecommerceservice._2007_05_14.Cart; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartAdd; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartAddRequest; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartAddResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartClear; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartClearResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartCreate; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartCreateResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartGet; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartGetResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartItem; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartItems; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartModify; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartModifyResponse; + +@Scope("COMPOSITE") +public class CartServiceImpl implements CartService { + + private static long ID = 0; + + private HashMap cartsHash = new HashMap(); + + public CartAddResponse CartAdd(CartAdd cartAdd) { + System.out.println("Entering cartAdd..."); + System.out.println("CartServiceID: " + this.toString()); + CartAddResponse cartAddResponse = new CartAddResponse(); + + CartAddRequest cartAddRequest = cartAdd.getRequest().get(0); + + //Cart cart = getCart(cartAddRequest.getCartId()); + Cart cart = getCart(cartAdd.getAWSAccessKeyId()); + if(cart == null){ + cartAddResponse.getCart().add(new Cart()); + return cartAddResponse; + } + + CartItem cartItem = new CartItem(); + cartItem.setASIN(cartAddRequest.getItems().getItem().get(0).getASIN()); + cartItem.setQuantity(cartAddRequest.getItems().getItem().get(0).getQuantity().toString()); + cart.getCartItems().getCartItem().add(cartItem); + cartAddResponse.getCart().add(cart); + System.out.println("Exiting cartAdd..."); + return cartAddResponse; + } + + public CartClearResponse CartClear(CartClear cartClear) { + System.out.println("CartServiceID: " + this.toString()); + System.out.println("Entering cartClear..."); + CartClearResponse cartClearResponse = new CartClearResponse(); + + //CartClearRequest cartClearRequest = cartClear.getRequest().get(0); + + //Cart cart = getCart(cartClearRequest.getCartId()); + Cart cart = getCart(cartClear.getAWSAccessKeyId()); + if(cart == null) { + cartClearResponse.getCart().add(new Cart()); + return cartClearResponse; + } + + cart.getCartItems().getCartItem().clear(); + + cartClearResponse.getCart().add(cart); + System.out.println("Exiting cartClear..."); + return cartClearResponse; + } + + public CartCreateResponse CartCreate(CartCreate cartCreate) { + System.out.println("CartServiceID: " + this.toString()); + System.out.println("Entering cartCreate..."); + CartCreateResponse cartCreateResponse = new CartCreateResponse(); + + Cart cart = getCart(cartCreate.getAWSAccessKeyId()); + if(cart != null){ + cartCreateResponse.getCart().add(cart); + System.out.println("User " + cartCreate.getAWSAccessKeyId() + " has already created a cart with ID: " + cart.getCartId()); + return cartCreateResponse; + } + + cart = new Cart(); + cart.setCartId(this.generateID()); + cart.setCartItems(new CartItems()); + addCart(cartCreate.getAWSAccessKeyId(), cart); + + cartCreateResponse.getCart().add(cart); + System.out.println("Exiting cartCreate..."); + return cartCreateResponse; + } + + public CartGetResponse CartGet(CartGet cartGet) { + System.out.println("CartServiceID: " + this.toString()); + System.out.println("Entering cartGet..."); + CartGetResponse cartGetResponse = new CartGetResponse(); + + //CartGetRequest cartGetRequest = cartGet.getRequest().get(0); + + //Cart cart = getCart(cartGetRequest.getCartId()); + Cart cart = getCart(cartGet.getAWSAccessKeyId()); + if(cart == null){ + cartGetResponse.getCart().add(new Cart()); + return cartGetResponse; + } + + cartGetResponse.getCart().add(cart); + System.out.println("Exiting cartGet..."); + return cartGetResponse; + } + + public CartModifyResponse CartModify(CartModify cartModify) { + // TODO Auto-generated method stub + return null; + } + + private synchronized String generateID(){ + ID++; + return String.valueOf(ID); + } + + + private Cart getCart(String cartId){ + Cart cart = null; + System.out.println(this.cartsHash.toString()); + cart = this.cartsHash.get(cartId); + return cart; + } + + private void addCart(String cartId, Cart cart){ + this.cartsHash.put(cartId, cart); + } +/* + public void start() { + System.out.println("Start CartService..."); + } + + public void stop() { + System.out.println("Stop CartService..."); + } +*/ +} diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/proxy/ShoppingStoreService.java b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/proxy/ShoppingStoreService.java new file mode 100644 index 0000000000..207125ac75 --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/proxy/ShoppingStoreService.java @@ -0,0 +1,30 @@ +package shoppingstore.services.proxy; + +import org.osoa.sca.annotations.Remotable; + +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartAdd; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartAddResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartClear; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartClearResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartCreate; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartCreateResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartGet; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartGetResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartModify; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartModifyResponse; + + +@Remotable +public interface ShoppingStoreService{ + + public CartCreateResponse CartCreate(CartCreate cartCreate); + + public CartAddResponse CartAdd(CartAdd cartAdd); + + public CartModifyResponse CartModify(CartModify cartModify); + + public CartClearResponse CartClear(CartClear cartClear); + + public CartGetResponse CartGet(CartGet cartGet); + +} diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/proxy/ShoppingStoreServiceImpl.java b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/proxy/ShoppingStoreServiceImpl.java new file mode 100644 index 0000000000..8a73631cbb --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/java/shoppingstore/services/proxy/ShoppingStoreServiceImpl.java @@ -0,0 +1,49 @@ +package shoppingstore.services.proxy; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +import shoppingstore.services.cart.CartService; + +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartAddResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartClearResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartCreateResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartGetResponse; +import com.amazon.webservices.awsecommerceservice._2007_05_14.CartModifyResponse; + +@Scope("COMPOSITE") +public class ShoppingStoreServiceImpl implements ShoppingStoreService { + + private CartService cartService; + + @Reference + public void setCartService(CartService cartService) { + this.cartService = cartService; + } + + public CartAddResponse CartAdd( + com.amazon.webservices.awsecommerceservice._2007_05_14.CartAdd cartAdd) { + return cartService.CartAdd(cartAdd); + } + + public CartClearResponse CartClear( + com.amazon.webservices.awsecommerceservice._2007_05_14.CartClear cartClear) { + return cartService.CartClear(cartClear); + } + + public CartCreateResponse CartCreate( + com.amazon.webservices.awsecommerceservice._2007_05_14.CartCreate cartCreate) { + return cartService.CartCreate(cartCreate); + } + + public CartGetResponse CartGet( + com.amazon.webservices.awsecommerceservice._2007_05_14.CartGet cartGet) { + return cartService.CartGet(cartGet); + } + + public CartModifyResponse CartModify( + com.amazon.webservices.awsecommerceservice._2007_05_14.CartModify cartModify) { + return cartService.CartModify(cartModify); + } + +} diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/resources/shoppingstore.composite b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/resources/shoppingstore.composite new file mode 100644 index 0000000000..f03ce10d3b --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/resources/shoppingstore.composite @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/resources/wsdl/shoppingstore.wsdl b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/resources/wsdl/shoppingstore.wsdl new file mode 100644 index 0000000000..22eba787c6 --- /dev/null +++ b/sandbox/axis2-1.4/tutorial/www-services/catalog-amazon/cart-amazon/src/main/resources/wsdl/shoppingstore.wsdl @@ -0,0 +1,3023 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3