TUSCANY-2727, remove www-services from 1.4

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@724305 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
antelder 2008-12-08 10:43:14 +00:00
parent f29a66c248
commit 0e250b6927
39 changed files with 0 additions and 21546 deletions

View file

@ -1,44 +0,0 @@
/*
* 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);
}

View file

@ -1,451 +0,0 @@
<?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>

View file

@ -1,120 +0,0 @@
/*
* 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);
}
}

View file

@ -1,33 +0,0 @@
<?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>

View file

@ -1,52 +0,0 @@
/*
* 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();
}
}

View file

@ -1,215 +0,0 @@
<?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-store</artifactId>
<version>1.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>tutorial-cart-amazon</artifactId>
<name>Apache Tuscany SCA Store Tutorial Amazon Cart</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-jetty</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-api</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-impl</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws-axis2</artifactId>
<version>1.4</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</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-databinding-sdo</artifactId>
<version>1.4</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</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</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</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>

View file

@ -1,99 +0,0 @@
/*
* 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")); }
*/
}

View file

@ -1,77 +0,0 @@
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.

View file

@ -1,74 +0,0 @@
<!--
* 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 name="sample-shoppingstore" default="compile">
<property name="server.class" value="shoppingstore.server.ShoppingStoreServer" />
<property name="server.jar" value="sample-shoppingstore.jar" />
<target name="init">
<mkdir dir="target/classes"/>
</target>
<target name="compile" depends="init">
<javac srcdir="src/main/java"
destdir="target/classes"
debug="on"
source="1.5"
target="1.5">
<classpath>
<pathelement location="../../lib/tuscany-sca-manifest.jar"/>
<pathelement location="./lib/AWS2007_05_14.jar"/>
</classpath>
</javac>
<copy todir="target/classes">
<fileset dir="src/main/resources"/>
</copy>
<jar destfile="target/${server.jar}" basedir="target/classes">
<manifest>
<attribute name="Main-Class" value="${server.class}" />
</manifest>
</jar>
</target>
<target name="run-classes">
<java classname="${test.class}"
fork="true">
<classpath>
<pathelement path="target/classes"/>
<pathelement location="../../lib/tuscany-sca-manifest.jar"/>
</classpath>
</java>
</target>
<target name="run">
<java classname="${server.class}"
fork="true">
<classpath>
<pathelement path="target/${server.jar}"/>
<pathelement location="../../lib/tuscany-sca-manifest.jar"/>
<pathelement location="./lib/AWS2007_05_14.jar"/>
</classpath>
</java>
</target>
<target name="clean">
<delete quiet="true" includeemptydirs="true">
<fileset dir="target"/>
</delete>
</target>
</project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 KiB

View file

@ -1,25 +0,0 @@
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");
}
}

View file

@ -1,35 +0,0 @@
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();
}

View file

@ -1,144 +0,0 @@
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<String, Cart> cartsHash = new HashMap<String, Cart>();
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...");
}
*/
}

View file

@ -1,30 +0,0 @@
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);
}

View file

@ -1,49 +0,0 @@
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);
}
}

View file

@ -1,20 +0,0 @@
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://webservices.amazon.com/AWSECommerceService/2007-05-14"
xmlns:tns="http://webservices.amazon.com/AWSECommerceService/2007-05-14"
xmlns:db="http://tuscany.apache.org/xmlns/databinding/1.0"
name="ShoppingStore">
<component name="ShoppingStoreServiceComponent">
<service name="ShoppingStoreService" >
<interface.wsdl interface="http://webservices.amazon.com/AWSECommerceService/2007-05-14#wsdl.interface(AWSECommerceServicePortType)" />
<binding.ws />
<db:databinding name="jaxb" />
</service>
<implementation.java class="shoppingstore.services.proxy.ShoppingStoreServiceImpl" />
<reference name="cartService" target="CartServiceComponent"></reference>
</component>
<component name="CartServiceComponent">
<implementation.java class="shoppingstore.services.cart.CartServiceImpl" />
</component>
</composite>

View file

@ -1,95 +0,0 @@
<?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-store</artifactId>
<version>1.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>tutorial-catalog-amazon</artifactId>
<packaging>jar</packaging>
<name>Apache Tuscany SCA Store Tutorial Amazon Catalog</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws-axis2</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-databinding-saxon</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-xquery</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-jetty</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
</build>
</project>

View file

@ -1,37 +0,0 @@
/*
* 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 catalog;
import org.apache.tuscany.sca.host.embedded.SCADomain;
/**
* This client program to invoke the Mortgage LoanApproval service
*/
public class CatalogClient {
public static void main(String[] args) throws Exception {
System.err.println("Please make sure you have the ids configured in catalog.composite");
SCADomain domain = SCADomain.newInstance("catalog.composite");
CatalogService ebay = domain.getService(CatalogService.class, "EBayCatalogService");
ebay.get();
CatalogService amazon = domain.getService(CatalogService.class, "AmazonCatalogService");
amazon.get();
}
}

View file

@ -1,28 +0,0 @@
/*
* 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 catalog;
/**
* @version $Rev$ $Date$
*/
public interface CatalogService {
String[] get();
}

View file

@ -1,31 +0,0 @@
/*
* 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 catalog.amazon;
import org.apache.tuscany.sca.databinding.annotation.DataBinding;
import org.osoa.sca.annotations.Remotable;
import org.w3c.dom.Node;
@Remotable
@DataBinding(value="org.w3c.dom.Node", wrapped=true)
public interface AmazonCatalogService {
Node ItemSearch(Node requestWrapper);
}

View file

@ -1,94 +0,0 @@
/*
* 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 catalog.amazon;
import java.util.HashMap;
import java.util.Map;
import org.apache.tuscany.sca.databinding.impl.DOMHelper;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import catalog.CatalogService;
import catalog.util.XPathHelper;
/**
* @version $Rev$ $Date$
*/
@Service(CatalogService.class)
public class AmazonCatalogServiceImpl implements CatalogService {
private static final String AMAZON_TNS = "http://webservices.amazon.com/AWSECommerceService/2007-09-21";
@Reference(name = "amazonFindItems")
protected AmazonCatalogService itemSearch;
@Property(name="AWSAccessKeyId", required=true)
protected String accessKeyId;
private Node amazonItemSearch(String keywords) throws Exception {
Document doc = DOMHelper.newDocument();
Element wrapper = doc.createElementNS(AMAZON_TNS, "ItemSearch");
doc.appendChild(wrapper);
Element key = doc.createElementNS(AMAZON_TNS, "AWSAccessKeyId");
key.appendChild(doc.createTextNode(accessKeyId));
wrapper.appendChild(key);
Element request = doc.createElementNS(AMAZON_TNS, "Request");
wrapper.appendChild(request);
Element keywordsElement = doc.createElementNS(AMAZON_TNS, "Keywords");
keywordsElement.appendChild(doc.createTextNode(keywords));
request.appendChild(keywordsElement);
Element searchIndex = doc.createElementNS(AMAZON_TNS, "SearchIndex");
searchIndex.appendChild(doc.createTextNode("All"));
request.appendChild(searchIndex);
// System.out.println(new Node2String().transform(doc, null));
Node result = itemSearch.ItemSearch(doc);
return result;
}
public String[] get() {
try {
Node list = amazonItemSearch("Fruit");
Map<String, String> map = new HashMap<String, String>();
map.put("a", AMAZON_TNS);
NodeList nodes =
XPathHelper.selectNodes("//a:Item/a:ItemAttributes[a:ProductGroup='Grocery']/a:Title", list, map);
String titles[] = new String[nodes.getLength()];
System.out.println("Amazon catalog:");
for (int i = 0; i < nodes.getLength(); i++) {
titles[i] = nodes.item(i).getTextContent();
System.out.println("[" + i + "]" + titles[i]);
}
return titles;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View file

@ -1,32 +0,0 @@
/*
* 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 catalog.ebay;
import org.osoa.sca.annotations.Remotable;
import org.w3c.dom.Node;
/**
* @version $Rev$ $Date$
*/
@Remotable
public interface EBayCatalogService {
Node FindItems(Node request);
Node GetUserProfile(Node request);
}

View file

@ -1,99 +0,0 @@
/*
* 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 catalog.ebay;
import java.util.HashMap;
import java.util.Map;
import org.apache.tuscany.sca.databinding.impl.DOMHelper;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import catalog.CatalogService;
import catalog.util.XPathHelper;
/**
* @version $Rev$ $Date$
*/
@Service(CatalogService.class)
public class EBayCatalogServiceImpl implements CatalogService {
private static final String EBAY_TNS = "urn:ebay:apis:eBLBaseComponents";
@Reference(name = "eBayFindItems")
protected EBayCatalogService findItems;
@Reference(name = "eBayGetUserProfile")
protected EBayCatalogService getUserProfile;
private Node eBayFindItems(String keywords, int maxEntries) throws Exception {
Document doc = DOMHelper.newDocument();
Element request = doc.createElementNS(EBAY_TNS, "FindItemsRequest");
doc.appendChild(request);
Element keywordsElement = doc.createElementNS(EBAY_TNS, "QueryKeywords");
keywordsElement.appendChild(doc.createTextNode(keywords));
Element maxEntriesElement = doc.createElementNS(EBAY_TNS, "MaxEntries");
maxEntriesElement.appendChild(doc.createTextNode(String.valueOf(maxEntries)));
Element messageIDElement = doc.createElementNS(EBAY_TNS, "MessageID");
messageIDElement.appendChild(doc.createTextNode("001"));
request.appendChild(maxEntriesElement);
request.appendChild(keywordsElement);
request.appendChild(messageIDElement);
// System.out.println(new Node2String().transform(doc, null));
Node result = findItems.FindItems(doc);
return result;
}
private Node eBayGetUserProfile(String userID) throws Exception {
Document doc = DOMHelper.newDocument();
Element req = doc.createElementNS(EBAY_TNS, "GetUserProfileRequest");
doc.appendChild(req);
Element user = doc.createElementNS(EBAY_TNS, "UserID");
user.appendChild(doc.createTextNode(userID));
Element msgID = doc.createElementNS(EBAY_TNS, "MessageID");
msgID.appendChild(doc.createTextNode("001"));
req.appendChild(user);
// System.out.println(new Node2String().transform(doc, null));
Node result = getUserProfile.GetUserProfile(doc);
return result;
}
public String[] get() {
try {
Node items = eBayFindItems("Fruit", 10);
Map<String, String> map = new HashMap<String, String>();
map.put("e", EBAY_TNS);
NodeList nodes = XPathHelper.selectNodes("//e:Item/e:Title", items, map);
String[] titles = new String[nodes.getLength()];
System.out.println("eBay catalog:");
for (int i = 0; i < nodes.getLength(); i++) {
titles[i] = nodes.item(i).getTextContent();
System.out.println("[" + i + "]" + titles[i]);
}
return titles;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View file

@ -1,126 +0,0 @@
/*
* 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 catalog.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.xml.namespace.NamespaceContext;
public class NamespaceContextImpl implements NamespaceContext {
private NamespaceContext parent;
private Map<String, String> map = new HashMap<String, String>();
/**
* @param parent
*/
public NamespaceContextImpl(NamespaceContext parent, Map<String, String> map) {
super();
this.parent = parent;
if (parent == null) {
this.map.put("xml", "http://www.w3.org/XML/1998/namespace");
this.map.put("xmlns", "http://www.w3.org/2000/xmlns/");
}
if (map != null) {
this.map.putAll(map);
}
}
public String getNamespaceURI(String prefix) {
if (prefix == null) {
throw new IllegalArgumentException("Prefix is null");
}
String ns = (String)map.get(prefix);
if (ns != null) {
return ns;
}
if (parent != null) {
return parent.getNamespaceURI(prefix);
}
return null;
}
public String getPrefix(String nsURI) {
if (nsURI == null)
throw new IllegalArgumentException("Namespace is null");
for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, String> entry = i.next();
if (entry.getValue().equals(nsURI)) {
return entry.getKey();
}
}
if (parent != null) {
return parent.getPrefix(nsURI);
}
return null;
}
public Iterator getPrefixes(String nsURI) {
List<String> prefixList = new ArrayList<String>();
for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, String> entry = i.next();
if (entry.getValue().equals(nsURI)) {
prefixList.add(entry.getKey());
}
}
final Iterator currentIterator = prefixList.iterator();
final Iterator parentIterator = parent != null ? null : parent.getPrefixes(nsURI);
return new Iterator() {
public boolean hasNext() {
return currentIterator.hasNext() || (parentIterator != null && parentIterator.hasNext());
}
public Object next() {
if (!hasNext()) {
throw new IllegalStateException("End of iterator has reached");
}
return currentIterator.hasNext() ? currentIterator.next() : parentIterator.next();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
public void register(String prefix, String ns) {
map.put(prefix, ns);
}
public NamespaceContext getParent() {
return parent;
}
public String toString() {
StringBuffer sb = new StringBuffer(map.toString());
if (parent != null) {
sb.append("\nParent: ");
sb.append(parent);
}
return sb.toString();
}
}

View file

@ -1,55 +0,0 @@
/*
* 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 catalog.util;
import java.util.Map;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* @version $Rev$ $Date$
*/
public class XPathHelper {
public static Node selectNode(String xpath, Node root, Map<String, String> namespaces)
throws XPathExpressionException {
XPath path = XPathFactory.newInstance().newXPath();
NamespaceContextImpl context = new NamespaceContextImpl(null, namespaces);
path.setNamespaceContext(context);
XPathExpression exp = path.compile(xpath);
return (Node)exp.evaluate(root, XPathConstants.NODE);
}
public static NodeList selectNodes(String xpath, Node root, Map<String, String> namespaces)
throws XPathExpressionException {
XPath path = XPathFactory.newInstance().newXPath();
NamespaceContextImpl context = new NamespaceContextImpl(null, namespaces);
path.setNamespaceContext(context);
XPathExpression exp = path.compile(xpath);
return (NodeList)exp.evaluate(root, XPathConstants.NODESET);
}
}

View file

@ -1,55 +0,0 @@
<?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:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
targetNamespace="http://catalog" name="Shopping">
<component name="EBayCatalogService">
<implementation.java class="catalog.ebay.EBayCatalogServiceImpl" />
</component>
<component name="AmazonCatalogService">
<implementation.java class="catalog.amazon.AmazonCatalogServiceImpl" />
<property name="AWSAccessKeyId">[Your Amazon Web Service Access Key Id]</property>
</component>
<reference name="eBayFindItems"
promote="EBayCatalogService/eBayFindItems">
<binding.ws
wsdlElement="urn:ebay:apis:eBLBaseComponents#wsdl.binding(ShoppingBinding)"
uri="http://open.api.ebay.com/shopping?version=535&amp;appid=[Your eBay application id]&amp;callname=FindItems&amp;requestencoding=SOAP" />
</reference>
<reference name="eBayGetUserProfile"
promote="EBayCatalogService/eBayGetUserProfile">
<binding.ws
wsdlElement="urn:ebay:apis:eBLBaseComponents#wsdl.binding(ShoppingBinding)"
uri="http://open.api.ebay.com/shopping?version=535&amp;appid=[Your eBay application id]&amp;callname=GetUserProfile&amp;requestencoding=SOAP" />
</reference>
<reference name="amazonFindItems"
promote="AmazonCatalogService/amazonFindItems">
<binding.ws
wsdlElement="http://webservices.amazon.com/AWSECommerceService/2007-09-21#wsdl.binding(AWSECommerceServiceBinding)"
uri="http://soap.amazon.com/onca/soap?Service=AWSECommerceService&amp;Operation=ItemSearch" />
</reference>
</composite>

View file

@ -1,149 +0,0 @@
<?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-store</artifactId>
<version>1.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>tutorial-store-db</artifactId>
<name>Apache Tuscany SCA Store Tutorial Catalog Database</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-host-jetty</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tutorial-assets</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-api</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-impl</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-sca-axis2</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.3.1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-maven-ant-generator</artifactId>
<version>1.4</version>
<executions>
<execution>
<configuration>
<mainClass>launch.LaunchCatalog</mainClass>
</configuration>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.1.2.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>create-db</id>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
<url>jdbc:derby:target/store_db;create=true</url>
<autocommit>true</autocommit>
<onError>continue</onError>
<delimiter>;</delimiter>
<srcFiles>
<srcFile>${pom.basedir}/store.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,34 +0,0 @@
/*
* 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.host.embedded.SCADomain;
public class LaunchCatalog {
public static void main(String[] args) throws Exception {
System.out.println("Starting ...");
SCADomain scaDomain = SCADomain.newInstance("store-catalog-database.composite");
System.out.println("store-catalog-database.composite ready for big business !!!");
System.in.read();
System.out.println("Stopping ...");
scaDomain.close();
System.out.println();
}
}

View file

@ -1,27 +0,0 @@
/*
* 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 {
String[] get();
}

View file

@ -1,120 +0,0 @@
/*
* 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 java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
public class CatalogImpl implements Catalog {
@Property
public String currencyCode = "USD";
@Reference
public CurrencyConverter currencyConverter;
private String currencySymbol;
public String[] get() {
String[] catalogArray = null;
String itemName;
float itemPrice;
String itemCurrencyCode;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
currencySymbol = currencyConverter.getCurrencySymbol(currencyCode);
try {
//initialize driver and register it with DriverManager
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
conn = DriverManager.getConnection(
"jdbc:derby:target/store_db",
"",
"");
pstmt = conn.prepareStatement("select * from \"Catalog\"",
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = pstmt.executeQuery();
rs.last();
catalogArray = new String[rs.getRow()];
do {
itemName = rs.getString(2);
itemPrice = rs.getFloat(4);
itemCurrencyCode = rs.getString(3);
catalogArray[rs.getRow()-1] = new String(itemName+" - "+
currencySymbol+" "+
currencyConverter.getConversion(itemCurrencyCode, currencyCode, itemPrice));
} while(rs.previous());
} catch (SQLException ex) {
ex.printStackTrace();
}catch (ClassNotFoundException ex) {
ex.printStackTrace();
} finally {
cleanup(conn,pstmt,rs);
}
return catalogArray;
}
private void cleanup(Connection conn, PreparedStatement pstmt, ResultSet rs) {
if (rs!=null) {
try {
rs.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
if (pstmt!=null) {
try {
pstmt.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
if (conn!=null) {
try {
conn.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
}

View file

@ -1,29 +0,0 @@
/*
* 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 CurrencyConverter {
public float getConversion(String fromCurrenycCode, String toCurrencyCode, float amount);
public String getCurrencySymbol(String currencyCode);
}

View file

@ -1,79 +0,0 @@
package util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class CreateDB {
public static void main(String[] args) {
System.out.println("Creating database ...");
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
//initialize driver and register it with DriverManager
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
//connect and create the db if not present
connection = DriverManager.getConnection(
"jdbc:derby:target/store_db;create=true",
"",
"");
try {
preparedStatement = connection.prepareStatement("DROP TABLE CATALOG");
preparedStatement.execute();
}catch(Exception e) {
//ignore to avoid erros when db is being created from scratch
}
preparedStatement = connection.prepareStatement("CREATE TABLE CATALOG("
+ "id NUMERIC(5 , 0) NOT NULL,"
+ "product_name VARCHAR(30),"
+ "currency_code CHAR(3),"
+ "price REAL,"
+ "primary key (id)"
+ ")");
preparedStatement.execute();
preparedStatement = connection.prepareStatement("INSERT INTO CATALOG VALUES(0,'Apple', 'USD', 2.99)");
preparedStatement.execute();
preparedStatement = connection.prepareStatement("INSERT INTO CATALOG VALUES(1,'Orange', 'USD', 3.55)");
preparedStatement.execute();
preparedStatement = connection.prepareStatement("INSERT INTO CATALOG VALUES(2,'Pear', 'USD', 1.55)");
preparedStatement.execute();
System.out.println("Done !");
} catch (SQLException ex) {
ex.printStackTrace();
}catch (ClassNotFoundException ex) {
ex.printStackTrace();
} finally {
if (preparedStatement!=null) {
try {
preparedStatement.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
if (connection!=null) {
try {
connection.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
}
}

View file

@ -1,31 +0,0 @@
<?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"
xmlns:s="http://store"
name="store-catalog-database">
<component name="Catalog">
<implementation.java class="services.CatalogImpl"/>
<property name="currencyCode">USD</property>
<reference name="currencyConverter" target="CurrencyConverter"/>
</component>
</composite>

View file

@ -1,37 +0,0 @@
--
-- 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.
--
DROP TABLE CATALOG;
CREATE TABLE CATALOG(
id NUMERIC(5 , 0) NOT NULL,
product_name VARCHAR(30),
currency_code CHAR(3),
price REAL,
primary key (id)
);
INSERT INTO CATALOG
VALUES(0,'Apple', 'USD', 2.99);
INSERT INTO CATALOG
VALUES(1,'Orange', 'USD', 3.55);
INSERT INTO CATALOG
VALUES(2,'Pear', 'USD', 1.55);

View file

@ -1,46 +0,0 @@
<?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-store</artifactId>
<version>1.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>tutorial-www-services</artifactId>
<packaging>pom</packaging>
<name>Apache Tuscany SCA Store Tutorial External Web Services</name>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>cart-amazon</module>
<module>catalog-amazon</module>
</modules>
</profile>
</profiles>
</project>