diff options
Diffstat (limited to 'sandbox')
7 files changed, 92 insertions, 13 deletions
diff --git a/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java b/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java index cb80368918..64a1487f72 100644 --- a/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java +++ b/sandbox/travelsample/contributions/introducing-client-contribution/src/main/java/scatours/client/TestClient.java @@ -19,6 +19,8 @@ package scatours.client;
+import java.math.BigDecimal;
+
import com.tuscanyscatours.Bookings;
import com.tuscanyscatours.Checkout;
@@ -40,7 +42,6 @@ public class TestClient { String bookingCode = bookings.newBooking("FS1APR4", 1);
System.out.println("Booking code is " + bookingCode);
- checkout.makePayment(1995.00, "1234567843218765 10/10");
- System.out.println("Paid $1995.00");
+ checkout.makePayment(new BigDecimal("1995.00"), "1234567843218765 10/10");
}
}
diff --git a/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java b/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java index 688fc7e83b..29c84d2bc0 100644 --- a/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java +++ b/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java @@ -18,9 +18,11 @@ */
package com.tuscanyscatours;
+import java.math.BigDecimal;
+
import org.osoa.sca.annotations.Remotable;
@Remotable
public interface Checkout {
- void makePayment(double amount, String cardInfo);
+ void makePayment(BigDecimal amount, String cardInfo);
}
diff --git a/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java b/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java index 68bf25a8cd..09e5d322a3 100644 --- a/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java +++ b/sandbox/travelsample/contributions/introducing-tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java @@ -18,11 +18,22 @@ */
package com.tuscanyscatours;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
public class ShoppingCart implements Checkout, Updates {
- public void makePayment(double amount, String cardInfo) {
- // make payment for trips in cart giving card details
+ private static List<String> bookedTrips = new ArrayList<String>();
+
+ public void makePayment(BigDecimal amount, String cardInfo) {
+ System.out.print("Charged $" + amount + " to card " + cardInfo + " for trips" );
+ for (String trip : bookedTrips){
+ System.out.print(" " + trip);
+ }
+ System.out.println();
+ bookedTrips.clear();
}
public void addTrip(String resCode) {
- // add the booked trip to the cart
+ bookedTrips.add(resCode);
}
}
diff --git a/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java b/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java new file mode 100644 index 0000000000..a8e3ea5ccf --- /dev/null +++ b/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Bookings.java @@ -0,0 +1,26 @@ +/* + * 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; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Bookings { + String newBooking(String trip, int people); +} diff --git a/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java b/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java new file mode 100644 index 0000000000..3b8f8b3130 --- /dev/null +++ b/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/Checkout.java @@ -0,0 +1,28 @@ +/* + * 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; + +import java.math.BigDecimal; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Checkout { + void makePayment(BigDecimal amount, String cardInfo); +} diff --git a/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java b/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java index 8ed40a8c06..764a8c0854 100644 --- a/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java +++ b/sandbox/travelsample/launchers/introducing-launcher/src/main/java/scatours/LaunchNode.java @@ -19,6 +19,9 @@ package scatours;
+import java.io.IOException;
+import java.math.BigDecimal;
+
import org.apache.tuscany.sca.node.SCAClient;
import org.apache.tuscany.sca.node.SCAContribution;
import org.apache.tuscany.sca.node.SCANode;
@@ -33,16 +36,24 @@ public class LaunchNode { // OK for development but you must launch the node from this module
public static void launchFromFileSystemDir(){
try {
- SCANode node = SCANodeFactory.newInstance().createSCANode("scatours.composite",
+ SCANode node = SCANodeFactory.newInstance().createSCANode(null,
new SCAContribution("goodvaluetrips", "../../contributions/introducing-goodvaluetrips-contribution/target/classes"),
- new SCAContribution("tuscanyscatours", "../../contributions/introducing-tuscanyscatours-contribution/target/classes"),
- new SCAContribution("client", "../../contributions/introducing-client-contribution/target/classes"),
- new SCAContribution("launcher", "./target/classes"));
+ new SCAContribution("tuscanyscatours", "../../contributions/introducing-tuscanyscatours-contribution/target/classes"));
+
node.start();
- Runnable runner = ((SCAClient)node).getService(Runnable.class, "TestClient/Runnable");
- runner.run();
+ Bookings bookings = ((SCAClient)node).getService(Bookings.class,
+ "TripBooking/Bookings");
+ System.out.println("Trip boooking code = " +
+ bookings.newBooking("FS1APR4", 1));
+
+ Checkout checkout = ((SCAClient)node).getService(Checkout.class,
+ "ShoppingCart/Checkout");
+
+ checkout.makePayment(new BigDecimal("1995.00"), "1234567843218765 10/10");
+
+
node.stop();
} catch (Throwable th) {
diff --git a/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite b/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite index a5e26fd7b7..eaa19f6174 100644 --- a/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite +++ b/sandbox/travelsample/launchers/introducing-launcher/src/main/resources/scatours.composite @@ -23,7 +23,7 @@ xmlns:tours="http://tuscanyscatours.com/"
xmlns:trips="http://goodvaluetrips.com/"
name="scatours">
-
+
<include name="client:Client" />
<include name="tours:Tours" />
<include name="trips:Trips" />
|