diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-25 18:00:45 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-25 18:00:45 +0000 |
commit | 3852b601e7c5d71282cb5e37e9c6ce6e648503a2 (patch) | |
tree | 65e9367a1a4e6b3386f3b745f0611fb13ac67396 /sandbox/travelsample/shoppingcart-contribution/src | |
parent | fcc6917ad657da26eedccadf3e7b8d81d410b6a7 (diff) |
switch components so that the booking component talks directly to the trip suppliers.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@737553 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/shoppingcart-contribution/src')
2 files changed, 38 insertions, 16 deletions
diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java index a7ad6e0a18..f7595c71fe 100644 --- a/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java +++ b/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java @@ -19,15 +19,21 @@ package scatours.shoppingcart; import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; import org.osoa.sca.annotations.Remotable; +import scatours.common.TripItem; + /** * The ShoppingCart service interface */ @Remotable @Conversational public interface ShoppingCart{ - void addItem(String itemId); - void removeItem(String itemId); - String[] getItems(); + void addTrip(TripItem trip); + void removeTrip(TripItem trip); + TripItem[] getTrips(); + + @EndsConversation + void checkout(String name); } diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java index 2278a85b0d..4fc9306785 100644 --- a/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java +++ b/sandbox/travelsample/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java @@ -27,12 +27,14 @@ import java.util.Map; import org.osoa.sca.annotations.ConversationID; import org.osoa.sca.annotations.Destroy; import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; import org.osoa.sca.annotations.Scope; import org.osoa.sca.annotations.Service; import scatours.common.TripItem; +import scatours.paymentprocess.PaymentProcess; /** * An implementation of the Trip service @@ -40,34 +42,48 @@ import scatours.common.TripItem; @Scope("CONVERSATION") @Service(interfaces={ShoppingCart.class}) public class ShoppingCartImpl implements ShoppingCart{ + + @Reference + protected PaymentProcess paymentProcess; @ConversationID - protected String conversationId; + protected String cartId; - private List<String> itemIds = new ArrayList<String>(); + private List<TripItem> trips = new ArrayList<TripItem>(); // Trip methods @Init - public void initTrip() { - System.out.println("Cart init for id: " + conversationId); + public void initCart() { + System.out.println("Cart init for id: " + cartId); } @Destroy - public void destroyTrip() { - System.out.println("Cart destroy for id: " + conversationId); + public void destroyCart() { + System.out.println("Cart destroy for id: " + cartId); } + public void addTrip(TripItem trip) { + trips.add(trip); + } - public void addItem(String itemId){ - itemIds.add(itemId); + public void removeTrip(TripItem trip) { + trips.remove(trip); } - public void removeItem(String itemId){ - itemIds.remove(itemId); + public TripItem[] getTrips(){ + return trips.toArray(new TripItem[trips.size()]); + } + + public void checkout(String customerName){ + // get users credentials. Hard coded for now but should + // come from the security context + String customerId = customerName; + + // get the total for all the trips + float amount = (float)0.0; + + paymentProcess.makePayment(customerId, amount); } - public String[] getItems() { - return itemIds.toArray(new String[itemIds.size()]); - } } |