summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src
diff options
context:
space:
mode:
authornash <nash@13f79535-47bb-0310-9956-ffa450edef68>2009-02-08 17:53:30 +0000
committernash <nash@13f79535-47bb-0310-9956-ffa450edef68>2009-02-08 17:53:30 +0000
commitf25043a11e089fe743cf00304f735941e07c70d6 (patch)
tree4ec68ccae2fb2cd8e94121d7d2b60b109df08d74 /sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src
parent0e4846e9b7eed9d2acf12a5924105ede04fe839b (diff)
Add code for chapter 2
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@742134 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src')
-rw-r--r--sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/goodvaluetrips/Trips.java26
-rw-r--r--sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Bookings.java26
-rw-r--r--sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java26
-rw-r--r--sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java28
-rw-r--r--sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/TripBooking.java35
-rw-r--r--sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Updates.java26
-rw-r--r--sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/resources/tours.composite46
7 files changed, 213 insertions, 0 deletions
diff --git a/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/goodvaluetrips/Trips.java b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/goodvaluetrips/Trips.java
new file mode 100644
index 0000000000..365a210368
--- /dev/null
+++ b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/goodvaluetrips/Trips.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 com.goodvaluetrips;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface Trips {
+ String checkAvailability(String trip, int people);
+}
diff --git a/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Bookings.java b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Bookings.java
new file mode 100644
index 0000000000..9d54d46bb6
--- /dev/null
+++ b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/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 com.tuscanyscatours;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface Bookings {
+ String newBooking(String trip, int people);
+}
diff --git a/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java
new file mode 100644
index 0000000000..688fc7e83b
--- /dev/null
+++ b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.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 com.tuscanyscatours;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface Checkout {
+ void makePayment(double amount, String cardInfo);
+}
diff --git a/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java
new file mode 100644
index 0000000000..68bf25a8cd
--- /dev/null
+++ b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.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 com.tuscanyscatours;
+
+public class ShoppingCart implements Checkout, Updates {
+ public void makePayment(double amount, String cardInfo) {
+ // make payment for trips in cart giving card details
+ }
+ public void addTrip(String resCode) {
+ // add the booked trip to the cart
+ }
+}
diff --git a/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/TripBooking.java b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/TripBooking.java
new file mode 100644
index 0000000000..e64d60545e
--- /dev/null
+++ b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/TripBooking.java
@@ -0,0 +1,35 @@
+/*
+ * 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 com.tuscanyscatours;
+
+import org.osoa.sca.annotations.Reference;
+
+public class TripBooking implements Bookings {
+ @Reference
+ protected com.goodvaluetrips.Trips mytrips;
+
+ @Reference
+ protected Updates cart;
+
+ public String newBooking(String trip, int people) {
+ String resCode = mytrips.checkAvailability(trip, people);
+ cart.addTrip(resCode);
+ return "GV" + resCode;
+ }
+}
diff --git a/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Updates.java b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Updates.java
new file mode 100644
index 0000000000..e33b0399cb
--- /dev/null
+++ b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Updates.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 com.tuscanyscatours;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface Updates {
+ void addTrip(String resCode);
+}
diff --git a/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/resources/tours.composite b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/resources/tours.composite
new file mode 100644
index 0000000000..62fa1fd792
--- /dev/null
+++ b/sandbox/travelsample/chapter-02/tuscanyscatours-contribution/src/main/resources/tours.composite
@@ -0,0 +1,46 @@
+<?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://tuscanyscatours.com/"
+ name="tours">
+
+ <component name="TripBooking">
+ <implementation.java class="com.tuscanyscatours.TripBooking" />
+ <service name="Bookings">
+ <interface.java interface="com.tuscanyscatours.Bookings" />
+ </service>
+ <reference name="mytrips" target="TripProvider/Trips">
+ <interface.java interface="com.goodvaluetrips.Trips" />
+ </reference>
+ <reference name="cart" target="ShoppingCart/Updates">
+ <interface.java interface="com.tuscanyscatours.Updates" />
+ </reference>
+ </component>
+
+ <component name="ShoppingCart">
+ <implementation.java class="com.tuscanyscatours.ShoppingCart"/>
+ <service name="Checkout">
+ <interface.java interface="com.tuscanyscatours.Checkout" />
+ </service>
+ <service name="Updates">
+ <interface.java interface="com.tuscanyscatours.Updates" />
+ </service>
+ </component>
+</composite>