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/www-services/cart-amazon |
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/www-services/cart-amazon')
7 files changed, 1014 insertions, 0 deletions
diff --git a/java/sca/tutorial/www-services/cart-amazon/amazon/cart/AmazonCart.java b/java/sca/tutorial/www-services/cart-amazon/amazon/cart/AmazonCart.java new file mode 100644 index 0000000000..6f968bdba3 --- /dev/null +++ b/java/sca/tutorial/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/java/sca/tutorial/www-services/cart-amazon/amazon/cart/AmazonCart.wsdl b/java/sca/tutorial/www-services/cart-amazon/amazon/cart/AmazonCart.wsdl new file mode 100644 index 0000000000..051c8ad906 --- /dev/null +++ b/java/sca/tutorial/www-services/cart-amazon/amazon/cart/AmazonCart.wsdl @@ -0,0 +1,451 @@ +<?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. +--> +<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://amazon.cart.com/" targetNamespace="http://amazon.cart.com/">
+ <types>
+ <xs:schema targetNamespace="http://amazon.cart.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://amazon.cart.com/" elementFormDefault="qualified">
+ <xs:element name="CartGet">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="MarketplaceDomain" type="xs:string" minOccurs="0"/>
+ <xs:element name="AWSAccessKeyId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="Validate" type="xs:string" minOccurs="0"/>
+ <xs:element name="XMLEscaping" type="xs:string" minOccurs="0"/>
+ <xs:element name="Shared" type="tns:CartGetRequest" minOccurs="0"/>
+ <xs:element name="Request" type="tns:CartGetRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartGetRequest">
+ <xs:sequence>
+ <xs:element name="CartId" type="xs:string" minOccurs="0"/>
+ <xs:element name="HMAC" type="xs:string" minOccurs="0"/>
+ <xs:element name="MergeCart" type="xs:string" minOccurs="0"/>
+ <xs:element name="ResponseGroup" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="CartAdd">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="MarketplaceDomain" type="xs:string" minOccurs="0"/>
+ <xs:element name="AWSAccessKeyId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="Validate" type="xs:string" minOccurs="0"/>
+ <xs:element name="XMLEscaping" type="xs:string" minOccurs="0"/>
+ <xs:element name="Shared" type="tns:CartAddRequest" minOccurs="0"/>
+ <xs:element name="Request" type="tns:CartAddRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartAddRequest">
+ <xs:sequence>
+ <xs:element name="CartId" type="xs:string" minOccurs="0"/>
+ <xs:element name="HMAC" type="xs:string" minOccurs="0"/>
+ <xs:element name="MergeCart" type="xs:string" minOccurs="0"/>
+ <xs:element name="Items" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="OfferListingId" type="xs:string" minOccurs="0"/>
+ <xs:element name="Quantity" type="xs:positiveInteger" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="ListItemId" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="ResponseGroup" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="CartCreate">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="MarketplaceDomain" type="xs:string" minOccurs="0"/>
+ <xs:element name="AWSAccessKeyId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="Validate" type="xs:string" minOccurs="0"/>
+ <xs:element name="XMLEscaping" type="xs:string" minOccurs="0"/>
+ <xs:element name="Shared" type="tns:CartCreateRequest" minOccurs="0"/>
+ <xs:element name="Request" type="tns:CartCreateRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartCreateRequest">
+ <xs:sequence>
+ <xs:element name="MergeCart" type="xs:string" minOccurs="0"/>
+ <xs:element name="Items" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="OfferListingId" type="xs:string" minOccurs="0"/>
+ <xs:element name="Quantity" type="xs:positiveInteger" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="ListItemId" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="ResponseGroup" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="CartClear">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="MarketplaceDomain" type="xs:string" minOccurs="0"/>
+ <xs:element name="AWSAccessKeyId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
+ <xs:element name="AssociateTag" type="xs:string" minOccurs="0"/>
+ <xs:element name="Validate" type="xs:string" minOccurs="0"/>
+ <xs:element name="XMLEscaping" type="xs:string" minOccurs="0"/>
+ <xs:element name="Shared" type="tns:CartClearRequest" minOccurs="0"/>
+ <xs:element name="Request" type="tns:CartClearRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartClearRequest">
+ <xs:sequence>
+ <xs:element name="CartId" type="xs:string" minOccurs="0"/>
+ <xs:element name="HMAC" type="xs:string" minOccurs="0"/>
+ <xs:element name="MergeCart" type="xs:string" minOccurs="0"/>
+ <xs:element name="ResponseGroup" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="CartGetResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:OperationRequest" minOccurs="0"/>
+ <xs:element ref="tns:Cart" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CartAddResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:OperationRequest" minOccurs="0"/>
+ <xs:element ref="tns:Cart" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CartCreateResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:OperationRequest" minOccurs="0"/>
+ <xs:element ref="tns:Cart" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CartClearResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:OperationRequest" minOccurs="0"/>
+ <xs:element ref="tns:Cart" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Cart">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:Request" minOccurs="0"/>
+ <xs:element name="CartId" type="xs:string"/>
+ <xs:element name="HMAC" type="xs:string"/>
+ <xs:element name="URLEncodedHMAC" type="xs:string"/>
+ <xs:element name="PurchaseURL" type="xs:string" minOccurs="0"/>
+ <xs:element name="SubTotal" type="tns:Price" minOccurs="0"/>
+ <xs:element ref="tns:CartItems" minOccurs="0"/>
+ <xs:element ref="tns:SavedForLaterItems" minOccurs="0"/>
+ <xs:element ref="tns:SimilarProducts" minOccurs="0"/>
+ <xs:element ref="tns:TopSellers" minOccurs="0"/>
+ <xs:element ref="tns:NewReleases" minOccurs="0"/>
+ <xs:element ref="tns:SimilarViewedProducts" minOccurs="0"/>
+ <xs:element ref="tns:OtherCategoriesSimilarProducts" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="SavedForLaterItems">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="SubTotal" type="tns:Price" minOccurs="0"/>
+ <xs:element name="SavedForLaterItem" type="tns:CartItem" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="SimilarProducts">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="SimilarProduct" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="TopSellers">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="TopSeller" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="NewReleases">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="NewRelease" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="SimilarViewedProducts">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="SimilarViewedProduct" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="OtherCategoriesSimilarProducts">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="OtherCategoriesSimilarProduct" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="CartItems">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="SubTotal" type="tns:Price" minOccurs="0"/>
+ <xs:element name="CartItem" type="tns:CartItem" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="OperationRequest">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="tns:HTTPHeaders" minOccurs="0"/>
+ <xs:element name="RequestId" type="xs:string" minOccurs="0"/>
+ <xs:element ref="tns:Arguments" minOccurs="0"/>
+ <xs:element ref="tns:Errors" minOccurs="0"/>
+ <xs:element name="RequestProcessingTime" type="xs:float" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Request">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="CartGetRequest" type="tns:CartGetRequest" minOccurs="0"/>
+ <xs:element name="CartAddRequest" type="tns:CartAddRequest" minOccurs="0"/>
+ <xs:element name="CartCreateRequest" type="tns:CartCreateRequest" minOccurs="0"/>
+ <xs:element name="CartClearRequest" type="tns:CartClearRequest" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Arguments">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Argument" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="Name" type="xs:string" use="required"/>
+ <xs:attribute name="Value" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Errors">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Error" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Code" type="xs:string"/>
+ <xs:element name="Message" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="HTTPHeaders">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Header" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="Name" type="xs:string" use="required"/>
+ <xs:attribute name="Value" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="CartItem">
+ <xs:sequence>
+ <xs:element name="CartItemId" type="xs:string"/>
+ <xs:element name="ASIN" type="xs:string" minOccurs="0"/>
+ <xs:element name="ExchangeId" type="xs:string" minOccurs="0"/>
+ <xs:element name="MerchantId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SellerId" type="xs:string" minOccurs="0"/>
+ <xs:element name="SellerNickname" type="xs:string" minOccurs="0"/>
+ <xs:element name="Quantity" type="xs:string"/>
+ <xs:element name="Title" type="xs:string" minOccurs="0"/>
+ <xs:element name="ProductGroup" type="xs:string" minOccurs="0"/>
+ <xs:element name="ListOwner" type="xs:string" minOccurs="0"/>
+ <xs:element name="ListType" type="xs:string" minOccurs="0"/>
+ <xs:element name="Price" type="tns:Price" minOccurs="0"/>
+ <xs:element name="ItemTotal" type="tns:Price" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Price">
+ <xs:sequence>
+ <xs:element name="Amount" type="xs:integer" minOccurs="0"/>
+ <xs:element name="CurrencyCode" type="xs:string" minOccurs="0"/>
+ <xs:element name="FormattedPrice" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ </types>
+ <message name="CartGetRequestMsg">
+ <part name="body" element="tns:CartGet"/>
+ </message>
+ <message name="CartGetResponseMsg">
+ <part name="body" element="tns:CartGetResponse"/>
+ </message>
+ <message name="CartAddRequestMsg">
+ <part name="body" element="tns:CartAdd"/>
+ </message>
+ <message name="CartAddResponseMsg">
+ <part name="body" element="tns:CartAddResponse"/>
+ </message>
+ <message name="CartCreateRequestMsg">
+ <part name="body" element="tns:CartCreate"/>
+ </message>
+ <message name="CartCreateResponseMsg">
+ <part name="body" element="tns:CartCreateResponse"/>
+ </message>
+ <message name="CartClearRequestMsg">
+ <part name="body" element="tns:CartClear"/>
+ </message>
+ <message name="CartClearResponseMsg">
+ <part name="body" element="tns:CartClearResponse"/>
+ </message>
+ <portType name="AmazonCartServicePortType">
+ <operation name="CartGet">
+ <input message="tns:CartGetRequestMsg"/>
+ <output message="tns:CartGetResponseMsg"/>
+ </operation>
+ <operation name="CartAdd">
+ <input message="tns:CartAddRequestMsg"/>
+ <output message="tns:CartAddResponseMsg"/>
+ </operation>
+ <operation name="CartCreate">
+ <input message="tns:CartCreateRequestMsg"/>
+ <output message="tns:CartCreateResponseMsg"/>
+ </operation>
+ <operation name="CartClear">
+ <input message="tns:CartClearRequestMsg"/>
+ <output message="tns:CartClearResponseMsg"/>
+ </operation>
+ </portType>
+ <binding name="AmazonCartServiceBinding" type="tns:AmazonCartServicePortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="CartGet">
+ <soap:operation soapAction="http://soap.amazon.cart.com"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="CartCreate">
+ <soap:operation soapAction="http://soap.amazon.cart.com"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="CartAdd">
+ <soap:operation soapAction="http://soap.amazon.cart.com"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="CartClear">
+ <soap:operation soapAction="http://soap.amazon.cart.com"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="AmazonCartService">
+ <port name="AmazonCartServicePort" binding="tns:AmazonCartServiceBinding">
+ <soap:address location="http://localhost:8080/AmazonCartServiceComponent"/>
+ </port>
+ </service>
+</definitions>
diff --git a/java/sca/tutorial/www-services/cart-amazon/amazon/cart/AmazonCartImpl.java b/java/sca/tutorial/www-services/cart-amazon/amazon/cart/AmazonCartImpl.java new file mode 100644 index 0000000000..66d72c57c4 --- /dev/null +++ b/java/sca/tutorial/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<String, Cart> cartsHash = new HashMap<String, Cart>(); + + 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<CartItem> 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/java/sca/tutorial/www-services/cart-amazon/amazoncart.composite b/java/sca/tutorial/www-services/cart-amazon/amazoncart.composite new file mode 100644 index 0000000000..6f8cc7b878 --- /dev/null +++ b/java/sca/tutorial/www-services/cart-amazon/amazoncart.composite @@ -0,0 +1,33 @@ +<?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"
+ targetNamespace="http://amazonCart"
+ xmlns:tns="http://amazonCart"
+ name="amazonCart">
+
+ <component name="AmazonCartServiceComponent">
+ <implementation.java class="amazon.cart.AmazonCartImpl" />
+ <service name="AmazonCart">
+ <interface.wsdl interface="http://amazon.cart.com/#wsdl.interface(AmazonCartServicePortType)" />
+ <binding.ws />
+ </service>
+ </component>
+
+</composite>
\ No newline at end of file diff --git a/java/sca/tutorial/www-services/cart-amazon/launch/LaunchAmazonCart.java b/java/sca/tutorial/www-services/cart-amazon/launch/LaunchAmazonCart.java new file mode 100644 index 0000000000..69dd06c2ef --- /dev/null +++ b/java/sca/tutorial/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/java/sca/tutorial/www-services/cart-amazon/pom.xml b/java/sca/tutorial/www-services/cart-amazon/pom.xml new file mode 100644 index 0000000000..3e5d5983ed --- /dev/null +++ b/java/sca/tutorial/www-services/cart-amazon/pom.xml @@ -0,0 +1,215 @@ +<?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-cart-amazon</artifactId>
+ <name>Apache Tuscany SCA Tutorial Amazon Cart</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</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-ws-axis2</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-lib</artifactId>
+ <version>1.1-incubating</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-impl</artifactId>
+ <version>1.1-incubating</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <sourceDirectory>${basedir}</sourceDirectory>
+ <testSourceDirectory>${basedir}/test</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ <exclude>pom.xml</exclude>
+ <exclude>build.xml</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>target/sdo-source</source>
+ <source>target/wsdl2java-source</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-plugin</artifactId>
+ <version>1.1-incubating</version>
+ <executions>
+ <execution>
+ <configuration>
+ <schemaFile>${basedir}/amazon/cart/AmazonCart.wsdl</schemaFile>
+ <noNotification>true</noNotification>
+ <noContainer>true</noContainer>
+ <noInterfaces>true</noInterfaces>
+ <noUnsettable>true</noUnsettable>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <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>
+ <plugin>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-maven-wsdl2java</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <configuration>
+ <wsdlFile>${basedir}/amazon/cart/AmazonCart.wsdl</wsdlFile>
+ <javaPackage>amazon.cart.api</javaPackage>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-maven-ant-generator</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <configuration>
+ <mainClass>launch.LaunchAmazonCart</mainClass>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-trax</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
diff --git a/java/sca/tutorial/www-services/cart-amazon/test/AmazonCartTestCase.java b/java/sca/tutorial/www-services/cart-amazon/test/AmazonCartTestCase.java new file mode 100644 index 0000000000..ede97f7868 --- /dev/null +++ b/java/sca/tutorial/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")); } + */ +} |