diff options
Diffstat (limited to 'sandbox/travelsample')
25 files changed, 1289 insertions, 82 deletions
diff --git a/sandbox/travelsample/node/build.xml b/sandbox/travelsample/node/build.xml index e2fc7ebba1..7c4e2ae15a 100644 --- a/sandbox/travelsample/node/build.xml +++ b/sandbox/travelsample/node/build.xml @@ -155,7 +155,8 @@ <include name="axis2-kernel-1.4.1.jar"/> <include name="axis2-mtompolicy-1.4.1.jar"/> <include name="backport-util-concurrent-3.1.jar"/> - <include name="bcprov-jdk13-132.jar"/> + <include name="bcel-5.2.jar"/> + <include name="bcprov-jdk15-132.jar"/> <include name="cglib-nodep-2.1_3.jar"/> <include name="commons-codec-1.3.jar"/> <include name="commons-collections-3.1.jar"/> @@ -174,6 +175,7 @@ <include name="htmlparser-1.0.5.jar"/> <include name="httpcore-4.0-beta1.jar"/> <include name="httpcore-nio-4.0-beta1.jar"/> + <include name="jakarta-regexp-1.4.jar"/> <include name="jaxb-api-2.1.jar"/> <include name="jaxb-impl-2.1.7.jar"/> <include name="jaxen-1.1.1.jar"/> diff --git a/sandbox/travelsample/node/src/scatours/LaunchNode.java b/sandbox/travelsample/node/src/scatours/LaunchNode.java index 65483a10c9..aca8d7e026 100644 --- a/sandbox/travelsample/node/src/scatours/LaunchNode.java +++ b/sandbox/travelsample/node/src/scatours/LaunchNode.java @@ -42,8 +42,9 @@ public class LaunchNode { new SCAContribution("hotel", "../hotel-contribution/target/scatours-hotel-contribution.jar"), new SCAContribution("flight", "../flight-contribution/target/scatours-flight-contribution.jar"), new SCAContribution("car", "../car-contribution/target/scatours-car-contribution.jar"), - new SCAContribution("trip", "../trip-contribution/target/scatours-trip-contribution.jar"), - new SCAContribution("travel", "../trip-contribution/target/scatours-travel-contribution.jar"), + new SCAContribution("tripbooking", "../tripbooking-contribution/target/scatours-tripbooking-contribution.jar"), + new SCAContribution("travelcatalog", "../travelcatalog-contribution/target/scatours-travelcatalog-contribution.jar"), + new SCAContribution("scatours", "../scatours-contribution/target/scatours-scatours-contribution.jar"), new SCAContribution("ui", "../ui-contribution/target/scatours-ui-contribution.jar")); node.start(); @@ -71,8 +72,9 @@ public class LaunchNode { new SCAContribution("hotel", "../hotel-contribution/target/classes"), new SCAContribution("flight", "../flight-contribution/target/classes"), new SCAContribution("car", "../car-contribution/target/classes"), - new SCAContribution("trip", "../trip-contribution/target/classes"), - new SCAContribution("travel", "../travel-contribution/target/classes"), + new SCAContribution("tripbooking", "../tripbooking-contribution/target/classes"), + new SCAContribution("travelcatalog", "../travelcatalog-contribution/target/classes"), + new SCAContribution("scatours", "../scatours-contribution/target/classes"), new SCAContribution("ui", "../ui-contribution/target/classes")); node.start(); diff --git a/sandbox/travelsample/pom.xml b/sandbox/travelsample/pom.xml index e9da4e8541..4fdbd2f746 100644 --- a/sandbox/travelsample/pom.xml +++ b/sandbox/travelsample/pom.xml @@ -43,8 +43,10 @@ <module>flight-contribution</module> <module>car-contribution</module> <module>payment-contribution</module> - <module>trip-contribution</module> - <module>travel-contribution</module> + <module>travelcatalog-contribution</module> + <module>tripbooking-contribution</module> + <module>shoppingcart-contribution</module> + <module>scatours-contribution</module> <module>ui-contribution</module> <module>domain</module> diff --git a/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..f34665c92d --- /dev/null +++ b/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ +<?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"> + <import.java package="scatours.common"/> + <import.java package="scatours.currencyconverter"/> + <import.java package="scatours.travelcatalog"/> + <import.java package="scatours.tripbooking"/> + <export.java package="scatours"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/scatours-contribution/pom.xml b/sandbox/travelsample/scatours-contribution/pom.xml new file mode 100644 index 0000000000..588e69f5c1 --- /dev/null +++ b/sandbox/travelsample/scatours-contribution/pom.xml @@ -0,0 +1,100 @@ +<?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.4-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-scatours-contribution</artifactId> + <name>Apache Tuscany SCA Tours SCATours Contribution</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-data-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-common-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-currency-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-travelcatalog-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-tripbooking-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-shoppingcart-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <sourceDirectory>${basedir}/src</sourceDirectory> + <resources> + <resource> + <directory>${basedir}</directory> + <excludes> + <exclude>**/*.java</exclude> + <exclude>**/.*/**</exclude> + <exclude>pom.xml</exclude> + <exclude>build.xml</exclude> + <exclude>target/**</exclude> + <exclude>src/**</exclude> + </excludes> + </resource> + </resources> + </build> +</project> diff --git a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java new file mode 100644 index 0000000000..cc1cb960fe --- /dev/null +++ b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java @@ -0,0 +1,36 @@ +/* + * 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; + +import scatours.common.TripItem; + +/** + * The SCA Tours trip booking service interface + */ +@Remotable +public interface SCAToursBooking { + String newTrip(); + void addTripItem(String tripId, String tripItemId); + void removeTripItem(String tripId, String tripItemId); + TripItem[] getTripItems(String tripId); + double getTotalPrice(String tripId); +} diff --git a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java new file mode 100644 index 0000000000..727b55dd69 --- /dev/null +++ b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java @@ -0,0 +1,109 @@ +/* + * 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.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.RequestContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import scatours.common.Search; +import scatours.common.SearchCallback; +import scatours.common.TripItem; +import scatours.common.TripLeg; +import scatours.currencyconverter.CurrencyConverter; +import scatours.travelcatalog.TravelCatalogSearch; +import scatours.trip.Trip; +import scatours.tripbooking.TripBooking; + +/** + * An implementation of the Trip service + */ +@Scope("COMPOSITE") +@Service(interfaces={TravelCatalogSearch.class, SCAToursBooking.class}) +public class SCAToursImpl implements TravelCatalogSearch, SCAToursBooking{ + + @Reference + protected TravelCatalogSearch travelCatalogSearch; + + @Reference + protected TripBooking tripBooking; + + @Context + protected ComponentContext componentContext; + + private Map<String,TripBooking> trips = new HashMap<String,TripBooking>(); + private Map<String, TripItem> searchItemsCache = new HashMap<String, TripItem>(); + + // TravelSearch methods + + public TripItem[] search(TripLeg tripLeg) { + + TripItem[] searchItems = travelCatalogSearch.search(tripLeg); + + for (int i =0; i< searchItems.length; i++){ + searchItemsCache.put(searchItems[i].getId(), searchItems[i]); + } + return searchItems; + } + + // TravelBooking methods + + public String newTrip(){ + String tripId = UUID.randomUUID().toString(); + ServiceReference<TripBooking> tripReference = componentContext.getServiceReference(TripBooking.class, + "tripBooking"); + tripReference.setConversationID(tripId); + trips.put(tripId, tripReference.getService()); + return tripId; + } + + public void addTripItem(String tripId, String tripItemId){ + trips.get(tripId).addTripItem(searchItemsCache.get(tripItemId)); + } + + public void removeTripItem(String tripId, String tripItemId){ + trips.get(tripId).removeTripItem(tripItemId); + } + + public TripItem[] getTripItems(String tripId) { + return trips.get(tripId).getTripItems(); + } + + public double getTotalPrice(String tripId){ + return trips.get(tripId).getTripPrice(); + } + + public void bookTrip(String tripId) { + trips.get(tripId).bookTrip(); + } +} diff --git a/sandbox/travelsample/shoppingcart-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/shoppingcart-contribution/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..399b62f7aa --- /dev/null +++ b/sandbox/travelsample/shoppingcart-contribution/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"> + <import.java package="scatours.common"/> + <import.java package="scatours.currencyconverter"/> + <import.java package="scatours.tripbooking"/> + <export.java package="scatours.shoppingcart"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/shoppingcart-contribution/pom.xml b/sandbox/travelsample/shoppingcart-contribution/pom.xml new file mode 100644 index 0000000000..a013d86272 --- /dev/null +++ b/sandbox/travelsample/shoppingcart-contribution/pom.xml @@ -0,0 +1,88 @@ +<?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.4-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-shoppingcart-contribution</artifactId> + <name>Apache Tuscany SCA Tours Shopping Cart Contribution</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-data-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-common-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-currency-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-trip-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <sourceDirectory>${basedir}/src</sourceDirectory> + <resources> + <resource> + <directory>${basedir}</directory> + <excludes> + <exclude>**/*.java</exclude> + <exclude>**/.*/**</exclude> + <exclude>pom.xml</exclude> + <exclude>build.xml</exclude> + <exclude>target/**</exclude> + <exclude>src/**</exclude> + </excludes> + </resource> + </resources> + </build> +</project> diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelBooking.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelBooking.java new file mode 100644 index 0000000000..fec3ceb366 --- /dev/null +++ b/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelBooking.java @@ -0,0 +1,38 @@ +/* + * 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.travel; + + +import org.osoa.sca.annotations.Remotable; + +import scatours.common.TripItem; + +/** + * The TravelBooking service interface + */ +@Remotable +public interface TravelBooking { + + String newTrip(); + void addTripItem(String tripId, String id); + void removeTripItem(String tripId, String id); + TripItem[] getTripItems(String tripId); + double getTotalPrice(String tripId); + void purchaseTrip(String tripId); +} diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelImpl.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelImpl.java new file mode 100644 index 0000000000..cbd50e5b35 --- /dev/null +++ b/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelImpl.java @@ -0,0 +1,171 @@ +/* + * 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.travel; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.RequestContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import scatours.common.Search; +import scatours.common.SearchCallback; +import scatours.common.TripItem; +import scatours.common.TripLeg; +import scatours.currencyconverter.CurrencyConverter; +import scatours.trip.Trip; + +/** + * An implementation of the Trip service + */ +@Scope("COMPOSITE") +@Service(interfaces={TravelSearch.class, TravelBooking.class}) +public class TravelImpl implements TravelSearch, SearchCallback, TravelBooking{ + + @Reference + protected CurrencyConverter currencyConverter; + + @Reference + protected Search hotelSearch; + + @Reference + protected Search flightSearch; + + @Reference + protected Search carSearch; + + @Reference + protected Trip trip; + + @Property + public String quoteCurrencyCode = "USD"; + + @Context + protected ComponentContext componentContext; + + private int responsesReceived = 0; + + private List<TripItem> searchResults = new ArrayList<TripItem>(); + private Map<String,Trip> trips = new HashMap<String,Trip>(); + + // TravelSearch methods + + public TripItem[] search(TripLeg tripLeg) { + + searchResults.clear(); + responsesReceived = 0; + + ServiceReference<Search> dynamicHotelSearch = + componentContext.getServiceReference(Search.class, "hotelSearch"); + + dynamicHotelSearch.setCallbackID("HotelSearchCallbackID-" + tripLeg.getId()); + dynamicHotelSearch.getService().searchAsynch(tripLeg); + + flightSearch.searchAsynch(tripLeg); + carSearch.searchAsynch(tripLeg); + + while (responsesReceived < 3){ + try { + synchronized (this) { + this.wait(); + } + } catch (InterruptedException ex){ + // do nothing + } + } + + for (TripItem tripItem : searchResults){ + tripItem.setId(UUID.randomUUID().toString()); + tripItem.setTripId(tripLeg.getId()); + tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(), + quoteCurrencyCode, + tripItem.getPrice())); + tripItem.setCurrency(quoteCurrencyCode); + } + + return searchResults.toArray(new TripItem[searchResults.size()]); + } + + // SearchCallback methods + + public void searchResults(TripItem[] items){ + RequestContext requestContext = componentContext.getRequestContext(); + Object callbackID = requestContext.getServiceReference().getCallbackID(); + System.out.println(callbackID); + + for(int i = 0; i < items.length; i++ ){ + searchResults.add(items[i]); + } + + responsesReceived++; + try { + synchronized (this) { + this.notifyAll(); + } + } catch (Exception ex) { + } + } + + // TravelBooking methods + + public String newTrip(){ + String tripId = UUID.randomUUID().toString(); + ServiceReference<Trip> tripReference = componentContext.getServiceReference(Trip.class, + "trip"); + tripReference.setConversationID(tripId); + trips.put(tripId, tripReference.getService()); + return tripId; + } + + public void addTripItem(String tripId, String id){ + for (TripItem tripItem : searchResults) { + if (tripItem.getId().equals(id)){ + trips.get(tripId).addTripItem(tripItem); + } + } + } + + public void removeTripItem(String tripId, String id){ + trips.get(tripId).removeTripItem(id); + } + + public TripItem[] getTripItems(String tripId) { + return trips.get(tripId).getTripItems(); + } + + public double getTotalPrice(String tripId){ + return trips.get(tripId).getTripPrice(); + } + + public void purchaseTrip(String tripId) { + trips.get(tripId).purchaseTrip(); + } +} diff --git a/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelSearch.java b/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelSearch.java new file mode 100644 index 0000000000..d1aeed2906 --- /dev/null +++ b/sandbox/travelsample/shoppingcart-contribution/src/scatours/travel/TravelSearch.java @@ -0,0 +1,32 @@ +/* + * 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.travel; + +import org.osoa.sca.annotations.Remotable; + +import scatours.common.TripItem; +import scatours.common.TripLeg; + +/** + * The Trip service interface + */ +@Remotable +public interface TravelSearch { + TripItem[] search(TripLeg tripLeg); +} diff --git a/sandbox/travelsample/travelcatalog-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/travelcatalog-contribution/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..286b9c2a05 --- /dev/null +++ b/sandbox/travelsample/travelcatalog-contribution/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ +<?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"> + <import.java package="scatours.common"/> + <import.java package="scatours.currencyconverter"/> + <export.java package="scatours.travelcatalog"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/travelcatalog-contribution/pom.xml b/sandbox/travelsample/travelcatalog-contribution/pom.xml new file mode 100644 index 0000000000..dcf883209d --- /dev/null +++ b/sandbox/travelsample/travelcatalog-contribution/pom.xml @@ -0,0 +1,88 @@ +<?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.4-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-travelcatalog-contribution</artifactId> + <name>Apache Tuscany SCA Tours Travel Catalog Contribution</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-data-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-common-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-currency-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-trip-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <sourceDirectory>${basedir}/src</sourceDirectory> + <resources> + <resource> + <directory>${basedir}</directory> + <excludes> + <exclude>**/*.java</exclude> + <exclude>**/.*/**</exclude> + <exclude>pom.xml</exclude> + <exclude>build.xml</exclude> + <exclude>target/**</exclude> + <exclude>src/**</exclude> + </excludes> + </resource> + </resources> + </build> +</project> diff --git a/sandbox/travelsample/travelcatalog-contribution/src/scatours/travelcatalog/TravelCatalogImpl.java b/sandbox/travelsample/travelcatalog-contribution/src/scatours/travelcatalog/TravelCatalogImpl.java new file mode 100644 index 0000000000..f51004df3b --- /dev/null +++ b/sandbox/travelsample/travelcatalog-contribution/src/scatours/travelcatalog/TravelCatalogImpl.java @@ -0,0 +1,132 @@ +/* + * 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.travelcatalog; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.RequestContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import scatours.common.Search; +import scatours.common.SearchCallback; +import scatours.common.TripItem; +import scatours.common.TripLeg; +import scatours.currencyconverter.CurrencyConverter; +import scatours.trip.Trip; + +/** + * An implementation of the Trip service + */ +@Scope("COMPOSITE") +@Service(interfaces={TravelCatalogSearch.class}) +public class TravelCatalogImpl implements TravelCatalogSearch, SearchCallback{ + + @Reference + protected Search hotelSearch; + + @Reference + protected Search flightSearch; + + @Reference + protected Search carSearch; + + @Property + public String quoteCurrencyCode = "USD"; + + @Reference + protected CurrencyConverter currencyConverter; + + @Context + protected ComponentContext componentContext; + + private int responsesReceived = 0; + + private List<TripItem> searchResults = new ArrayList<TripItem>(); + + // TravelSearch methods + + public TripItem[] search(TripLeg tripLeg) { + + searchResults.clear(); + responsesReceived = 0; + + ServiceReference<Search> dynamicHotelSearch = + componentContext.getServiceReference(Search.class, "hotelSearch"); + + dynamicHotelSearch.setCallbackID("HotelSearchCallbackID-" + tripLeg.getId()); + dynamicHotelSearch.getService().searchAsynch(tripLeg); + + flightSearch.searchAsynch(tripLeg); + carSearch.searchAsynch(tripLeg); + + while (responsesReceived < 3){ + try { + synchronized (this) { + this.wait(); + } + } catch (InterruptedException ex){ + // do nothing + } + } + + for (TripItem tripItem : searchResults){ + tripItem.setId(UUID.randomUUID().toString()); + tripItem.setTripId(tripLeg.getId()); + tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(), + quoteCurrencyCode, + tripItem.getPrice())); + tripItem.setCurrency(quoteCurrencyCode); + } + + return searchResults.toArray(new TripItem[searchResults.size()]); + } + + // SearchCallback methods + + public void searchResults(TripItem[] items){ + RequestContext requestContext = componentContext.getRequestContext(); + Object callbackID = requestContext.getServiceReference().getCallbackID(); + System.out.println(callbackID); + + for(int i = 0; i < items.length; i++ ){ + searchResults.add(items[i]); + } + + responsesReceived++; + try { + synchronized (this) { + this.notifyAll(); + } + } catch (Exception ex) { + } + } +} diff --git a/sandbox/travelsample/travelcatalog-contribution/src/scatours/travelcatalog/TravelCatalogSearch.java b/sandbox/travelsample/travelcatalog-contribution/src/scatours/travelcatalog/TravelCatalogSearch.java new file mode 100644 index 0000000000..df22724de2 --- /dev/null +++ b/sandbox/travelsample/travelcatalog-contribution/src/scatours/travelcatalog/TravelCatalogSearch.java @@ -0,0 +1,32 @@ +/* + * 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.travelcatalog; + +import org.osoa.sca.annotations.Remotable; + +import scatours.common.TripItem; +import scatours.common.TripLeg; + +/** + * The Trip service interface + */ +@Remotable +public interface TravelCatalogSearch { + TripItem[] search(TripLeg tripLeg); +} diff --git a/sandbox/travelsample/tripbooking-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/tripbooking-contribution/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..5922c86cac --- /dev/null +++ b/sandbox/travelsample/tripbooking-contribution/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ +<?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"> + <import.java package="scatours.common"/> + <import.java package="scatours.currencyconverter"/> + <export.java package="scatours.tripbooking"/> +</contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/tripbooking-contribution/build.xml b/sandbox/travelsample/tripbooking-contribution/build.xml new file mode 100644 index 0000000000..b4fbc726cf --- /dev/null +++ b/sandbox/travelsample/tripbooking-contribution/build.xml @@ -0,0 +1,61 @@ +<!-- + * 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="gettingstarted" default="compile"> + <property environment="env"/> + + <target name="compile"> + <mkdir dir="target/classes"/> + <javac srcdir="src" destdir="target/classes" + debug="on" source="1.5" target="1.5"> + <classpath> + <pathelement location="${env.TUSCANY}/lib/tuscany-sca-manifest.jar"/> + </classpath> + </javac> + </target> + + <target name="run"> + <java classname="client.CurrencyConverterClient" fork="true"> + <classpath> + <pathelement path="src"/> + <pathelement path="target/classes"/> + <pathelement location="${env.TUSCANY}/lib/tuscany-sca-manifest.jar"/> + </classpath> + </java> + </target> + + <target name="runtrip"> + <java classname="client.TripClient" fork="true"> + <classpath> + <pathelement path="src"/> + <pathelement path="target/classes"/> + <pathelement location="${env.TUSCANY}/lib/tuscany-sca-manifest.jar"/> + </classpath> + </java> + </target> + + <target name="runtripws"> + <java classname="client.TripWsClient" fork="true"> + <classpath> + <pathelement path="src"/> + <pathelement path="target/classes"/> + <pathelement location="${env.TUSCANY}/lib/tuscany-sca-manifest.jar"/> + </classpath> + </java> + </target> +</project> diff --git a/sandbox/travelsample/tripbooking-contribution/pom.xml b/sandbox/travelsample/tripbooking-contribution/pom.xml new file mode 100644 index 0000000000..0df7341dd2 --- /dev/null +++ b/sandbox/travelsample/tripbooking-contribution/pom.xml @@ -0,0 +1,82 @@ +<?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.4-SNAPSHOT</version> + <!--relativePath>../../pom.xml</relativePath--> + </parent> + <artifactId>scatours-tripbooking-contribution</artifactId> + <name>Apache Tuscany SCA Tours Trip Booking Contribution</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-data-api</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-common-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-currency-contribution</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <sourceDirectory>${basedir}/src</sourceDirectory> + <resources> + <resource> + <directory>${basedir}</directory> + <excludes> + <exclude>**/*.java</exclude> + <exclude>**/.*/**</exclude> + <exclude>pom.xml</exclude> + <exclude>build.xml</exclude> + <exclude>target/**</exclude> + <exclude>src/**</exclude> + </excludes> + </resource> + </resources> + </build> +</project> diff --git a/sandbox/travelsample/tripbooking-contribution/src/scatours/tripbooking/TripBooking.java b/sandbox/travelsample/tripbooking-contribution/src/scatours/tripbooking/TripBooking.java new file mode 100644 index 0000000000..ae9ea00e61 --- /dev/null +++ b/sandbox/travelsample/tripbooking-contribution/src/scatours/tripbooking/TripBooking.java @@ -0,0 +1,46 @@ +/* + * 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.tripbooking; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Remotable; + +import scatours.common.TripItem; + +/** + * The Trip service interface + */ +@Remotable +@Conversational +public interface TripBooking { + + void addTripItem(TripItem tripItem); + + void removeTripItem(String tripItemId); + + TripItem[] getTripItems(); + + double getTripPrice(); + + @EndsConversation + void bookTrip(); +} diff --git a/sandbox/travelsample/tripbooking-contribution/src/scatours/tripbooking/TripBookingImpl.java b/sandbox/travelsample/tripbooking-contribution/src/scatours/tripbooking/TripBookingImpl.java new file mode 100644 index 0000000000..5133844fe1 --- /dev/null +++ b/sandbox/travelsample/tripbooking-contribution/src/scatours/tripbooking/TripBookingImpl.java @@ -0,0 +1,85 @@ +/* + * 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.tripbooking; + +import java.util.HashMap; +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.Scope; +import org.osoa.sca.annotations.Service; + + +import scatours.common.TripItem; + +/** + * An implementation of the Trip service + */ +@Scope("CONVERSATION") +@Service(interfaces={TripBooking.class}) +public class TripBookingImpl implements TripBooking{ + + @ConversationID + protected String conversationId; + + private Map<String, TripItem> tripItems = new HashMap<String, TripItem>(); + + // Trip methods + + @Init + public void initTrip() { + System.out.println("Trip init for id: " + conversationId); + } + + @Destroy + public void destroyTrip() { + System.out.println("Trip destroy for id: " + conversationId); + } + + + public void addTripItem(TripItem tripItem){ + tripItems.put(tripItem.getId(), tripItem); + } + + public void removeTripItem(String id){ + tripItems.remove(id); + } + + public TripItem[] getTripItems() { + return tripItems.values().toArray(new TripItem[tripItems.size()]); + } + + public double getTripPrice(){ + double totalPrice = 0.0; + + for (TripItem tripItem : tripItems.values()){ + totalPrice += tripItem.getPrice(); + } + + return totalPrice; + } + + public void bookTrip() { + // TODO + } +} diff --git a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml index debc0e2ea5..d3ea737a06 100644 --- a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml +++ b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml @@ -19,12 +19,13 @@ --> <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:scatours="http://scatours"> + <deployable composite="scatours:scatours"/> <import.java package="scatours.common"/> <import.java package="scatours.currencyconverter"/> <import.java package="scatours.hotel"/> <import.java package="scatours.flight"/> <import.java package="scatours.car"/> - <import.java package="scatours.trip"/> - <import.java package="scatours.travel"/> - <deployable composite="scatours:scatours"/> + <import.java package="scatours.tripbooking"/> + <import.java package="scatours.travelcatalog"/> + <import.java package="scatours"/> </contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/ui-contribution/build.xml b/sandbox/travelsample/ui-contribution/build.xml index 78f39b4176..2152c6fe8a 100644 --- a/sandbox/travelsample/ui-contribution/build.xml +++ b/sandbox/travelsample/ui-contribution/build.xml @@ -94,8 +94,10 @@ <include name="XmlSchema-1.4.2.jar"/> <include name="activation-1.1.jar"/> <include name="asm-all-3.1.jar"/> + <include name="bcel-5.2.jar"/> <include name="cglib-nodep-2.1_3.jar"/> <include name="geronimo-commonj_1.1_spec-1.0.jar"/> + <include name="jakarta-regexp-1.4.jar"/> <include name="jaxb-api-2.1.jar"/> <include name="jaxb-impl-2.1.7.jar"/> <include name="jaxws-api-2.1.jar"/> @@ -103,6 +105,8 @@ <include name="jsr250-api-1.0.jar"/> <include name="stax-api-1.0-2.jar"/> <include name="wstx-asl-3.2.4.jar"/> + <include name="xalan-2.7.0.jar"/> + <include name="xml-apis-1.3.03.jar"/> </fileset> </project> diff --git a/sandbox/travelsample/ui-contribution/scatours.composite b/sandbox/travelsample/ui-contribution/scatours.composite index 8e9a403d4a..e9193bf0fa 100644 --- a/sandbox/travelsample/ui-contribution/scatours.composite +++ b/sandbox/travelsample/ui-contribution/scatours.composite @@ -23,36 +23,35 @@ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" name="scatours"> - <component name="SCATours"> + <component name="UserInterfaceComponent"> <tuscany:implementation.widget location="scatours.html"/> <service name="Widget"> <tuscany:binding.http uri="/scatours"/> </service> - <reference name="hotel" target="HotelComponent"> + <reference name="scaToursSearch" target="SCAToursComponent/TravelCatalogSearch"> <tuscany:binding.jsonrpc/> - </reference> - <reference name="flight" target="FlightComponent"> - <tuscany:binding.jsonrpc/> - </reference> - <reference name="car" target="CarComponent"> - <tuscany:binding.jsonrpc/> - </reference> - <reference name="travelSearch" target="TravelComponent/TravelSearch"> + </reference> + <reference name="scaToursBooking" target="SCAToursComponent/SCAToursBooking"> <tuscany:binding.jsonrpc/> </reference> - <reference name="travelBooking" target="TravelComponent/TravelBooking"> - <tuscany:binding.jsonrpc/> - </reference> </component> - <component name="TravelComponent"> - <implementation.java class="scatours.travel.TravelImpl"/> - <service name="TravelSearch"> + <component name="SCAToursComponent"> + <implementation.java class="scatours.SCAToursImpl"/> + <service name="TravelCatalogSearch"> <tuscany:binding.jsonrpc/> </service> - <service name="TravelBooking"> + <service name="SCAToursBooking"> <tuscany:binding.jsonrpc/> </service> + <reference name="travelCatalogSearch" target="TravelCatalogComponent/TravelCatalogSearch"/> + <reference name="tripBooking" target="TripBookingComponent/TripBooking"/> + <!--reference name="shoppingCart" target="ShoppingCartComponent/shoppingCart"/--> + </component> + + <component name="TravelCatalogComponent"> + <implementation.java class="scatours.travelcatalog.TravelCatalogImpl"/> + <service name="TravelCatalogSearch"/> <reference name="hotelSearch" target="HotelComponent"> <binding.sca/> </reference> @@ -69,15 +68,12 @@ </reference> <reference name="currencyConverter" target="CurrencyConverterComponent"> </reference> - <reference name="trip" target="TripComponent"> - </reference> <property name="quoteCurrencyCode">GBP</property> </component> - <component name="TripComponent"> - <implementation.java class="scatours.trip.TripImpl"/> - <service name="Trip"> - </service> + <component name="TripBookingComponent"> + <implementation.java class="scatours.tripbooking.TripBookingImpl"/> + <service name="TripBooking"/> </component> <component name="HotelComponent"> @@ -114,5 +110,17 @@ <service name="CurrencyConverter"> </service> </component> + + <!-- component name="ShoppingCartComponent"> + <implementation.java class="scatours.shoppingcart.ShoppingCartImpl"/> + <service name="CurrencyConverter"> + </service> + </component> + + <component name="PaymentComponent"> + <implementation.java class="scatours.payment.PaymentImpl"/> + <service name="CurrencyConverter"> + </service> + </component--> </composite> diff --git a/sandbox/travelsample/ui-contribution/scatours.html b/sandbox/travelsample/ui-contribution/scatours.html index 54ee0c6b3d..d2a6baf669 100644 --- a/sandbox/travelsample/ui-contribution/scatours.html +++ b/sandbox/travelsample/ui-contribution/scatours.html @@ -24,27 +24,19 @@ <script type="text/javascript" src="scatours.js"></script> -<script language="JavaScript"> - - //@Reference - var hotel = new Reference("hotel"); - - //@Reference - var flight = new Reference("flight"); - - //@Reference - var car = new Reference("car"); +<script language="JavaScript"> //@Reference - var travelSearch = new Reference("travelSearch"); + var scaToursSearch = new Reference("scaToursSearch"); //@Reference - var travelBooking = new Reference("travelBooking"); + var scaToursBooking = new Reference("scaToursBooking"); //local state var currentTripId; - var searchResponseItems; - + var searchItems; + var cartItems; + //the constructor for trip leg beans function TripLegType(id, fromLocation, @@ -77,21 +69,9 @@ alert(e); } } - - function searchHotels() { - hotel.searchSynch(getTripLeg(), search_response); - } - - function searchFlights() { - flight.searchSynch(getTripLeg(), search_response); - } - - function searchCars() { - car.searchSynch(getTripLeg(), search_response); - } - - function searchPackages() { - travelSearch.search(getTripLeg(), search_response); + + function searchTravelCatalog() { + scaToursSearch.search(getTripLeg(), search_response); } function search_response(items, exception) { @@ -119,21 +99,27 @@ document.getElementById('searchResponse').innerHTML = responseHTML; - searchResponseItems = items; + searchItems = items; } - function processSelection() { + function processSelection() { + // do nothing at the moment + } + + function addItemsToCart() { var items = document.tripForm.items; - var j = 0; + for (var i=0; i<items.length; i++) { + + // notify the server of the change if (items[i].checked == true) { - travelBooking.addTripItem(currentTripId, items[i].value); + scaToursBooking.addTripItem(currentTripId, items[i].value); } else { - travelBooking.removeTripItem(currentTripId, items[i].value); + scaToursBooking.removeTripItem(currentTripId, items[i].value); } } - travelBooking.getTripItems(currentTripId,getTripItems_response); + scaToursBooking.getTripItems(currentTripId,getTripItems_response); } function getTripItems_response(items, exception) { @@ -160,7 +146,7 @@ document.getElementById('tripItems').innerHTML = itemsHTML; - travelBooking.getTotalPrice(currentTripId, getTotalPrice_response); + scaToursBooking.getTotalPrice(currentTripId, getTotalPrice_response); } function getTotalPrice_response(totalPrice, exception) { @@ -172,7 +158,7 @@ } function newTrip() { - travelBooking.newTrip(newTrip_response); + scaToursBooking.newTrip(newTrip_response); document.getElementById('searchResponse').innerHTML = ""; document.getElementById('tripItems').innerHTML = ""; @@ -185,18 +171,21 @@ return; } currentTripId = tripId - document.getElementById('tripId').innerHTML = "Trip: " + tripId; + document.getElementById('tripId').innerHTML = "Trip Reference: " + tripId; } - function purchaseTrip() { - travelBooking.purchaseTrip(currentTripId); + function bookTrip() { + travelBooking.bookTrip(currentTripId); document.getElementById('searchResponse').innerHTML = ""; document.getElementById('tripItems').innerHTML = "Thank you for shopping with SCA Tours"; document.getElementById('totalPrice').innerHTML = ""; searchResponseItems = null; tripItems = null; - } + } + + function purchase() { + } </script> @@ -234,22 +223,22 @@ </tr> </table> <br/> - <input type="button" onClick="searchPackages()" value="SearchPackages"> - <input type="button" onClick="searchHotels()" value="Search Hotels"> - <input type="button" onClick="searchFlights()" value="Search Flights"> - <input type="button" onClick="searchCars()" value="Search Cars"> + <input type="button" onClick="searchTravelCatalog()" value="Search"> </form> <form name="tripForm"> <h3>Search Results</h3> <div id="searchResponse"></div> - <br> + <br/> + <input type="button" onClick="addItemsToCart()" value="Add Items"> + <br/> + <h3>Shopping Cart</h3> <h3><div id="tripId"></h3> <div id="tripItems"></div> - <br> + <br/> <div id="totalPrice"></div> - <br> + <br/> + <input type="button" onClick="bookTrip()" value="Book"> <input type="button" onClick="newTrip()" value="Create New Trip"> - <input type="button" onClick="purchaseTrip()" value="Purchase Trip"> </form> </div> |