diff options
Diffstat (limited to 'sandbox/travelsample/shared-contributions/shoppingcart-contribution/src/scatours')
2 files changed, 128 insertions, 0 deletions
diff --git a/sandbox/travelsample/shared-contributions/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java b/sandbox/travelsample/shared-contributions/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java new file mode 100644 index 0000000000..f7595c71fe --- /dev/null +++ b/sandbox/travelsample/shared-contributions/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCart.java @@ -0,0 +1,39 @@ +/* + * 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 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 addTrip(TripItem trip); + void removeTrip(TripItem trip); + TripItem[] getTrips(); + + @EndsConversation + void checkout(String name); +} diff --git a/sandbox/travelsample/shared-contributions/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java b/sandbox/travelsample/shared-contributions/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java new file mode 100644 index 0000000000..5b6bc4007c --- /dev/null +++ b/sandbox/travelsample/shared-contributions/shoppingcart-contribution/src/scatours/shoppingcart/ShoppingCartImpl.java @@ -0,0 +1,89 @@ +/* + * 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 scatours.shoppingcart; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +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 + */ +@Scope("CONVERSATION") +@Service(interfaces={ShoppingCart.class}) +public class ShoppingCartImpl implements ShoppingCart{ + + // @Reference + // protected PaymentProcess paymentProcess; + + @ConversationID + protected String cartId; + + private List<TripItem> trips = new ArrayList<TripItem>(); + + // Trip methods + + @Init + public void initCart() { + System.out.println("Cart init for id: " + cartId); + } + + @Destroy + public void destroyCart() { + System.out.println("Cart destroy for id: " + cartId); + } + + public void addTrip(TripItem trip) { + trips.add(trip); + } + + public void removeTrip(TripItem trip) { + trips.remove(trip); + } + + 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); + } + +} |