diff options
Diffstat (limited to 'sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution')
10 files changed, 324 insertions, 0 deletions
diff --git a/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/build.xml b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/build.xml new file mode 100644 index 0000000000..d9961176f3 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/build.xml @@ -0,0 +1,44 @@ +<!--
+ * 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="scatours-chapter-02-tuscanyscatours-contribution" default="compile">
+ <property environment="env"/>
+
+ <target name="compile">
+ <mkdir dir="target/classes"/>
+ <javac destdir="target/classes" debug="on" source="1.5" target="1.5">
+ <src path="src/main/java"/>
+ <classpath>
+ <pathelement location="${env.TUSCANY}/lib/tuscany-sca-manifest.jar"/>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/scatours-chapter-02-tuscanyscatours-contribution.jar"
+ basedir="target/classes"/>
+ </target>
+
+ <target name="clean">
+ <delete includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+
+</project>
diff --git a/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/pom.xml b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/pom.xml new file mode 100644 index 0000000000..6296c58e95 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/pom.xml @@ -0,0 +1,42 @@ +<?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-sca</artifactId> + <version>1.6-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-chapter-02-tuscanyscatours-contribution</artifactId> + <name>Apache Tuscany SCA Tours Chapter 02 SCA Tours Contribution</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + </build> +</project> diff --git a/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/goodvaluetrips/Trips.java b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/goodvaluetrips/Trips.java new file mode 100644 index 0000000000..365a210368 --- /dev/null +++ b/sandbox/travelsample/contrib/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/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Bookings.java b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Bookings.java new file mode 100644 index 0000000000..9d54d46bb6 --- /dev/null +++ b/sandbox/travelsample/contrib/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/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Checkout.java new file mode 100644 index 0000000000..688fc7e83b --- /dev/null +++ b/sandbox/travelsample/contrib/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/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/ShoppingCart.java new file mode 100644 index 0000000000..68bf25a8cd --- /dev/null +++ b/sandbox/travelsample/contrib/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/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/TripBooking.java b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/TripBooking.java new file mode 100644 index 0000000000..e64d60545e --- /dev/null +++ b/sandbox/travelsample/contrib/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/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Updates.java b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/java/com/tuscanyscatours/Updates.java new file mode 100644 index 0000000000..e33b0399cb --- /dev/null +++ b/sandbox/travelsample/contrib/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/contrib/chapter-02/tuscanyscatours-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..cf1153ac14 --- /dev/null +++ b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ +<?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. +--> +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:tst="http://tuscanyscatours.com/"> + <export namespace="http://tuscanyscatours.com/" /> + <export.java package="com.tuscanyscatours" /> + <deployable composite="tst:Tours" /> +</contribution> diff --git a/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/resources/tours.composite b/sandbox/travelsample/contrib/chapter-02/tuscanyscatours-contribution/src/main/resources/tours.composite new file mode 100644 index 0000000000..f166a1635d --- /dev/null +++ b/sandbox/travelsample/contrib/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>
|