You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2008/08/10 17:15:28 UTC

svn commit: r684518 - in /tuscany/sandbox/travelsample: ./ node/src/scatours/ travel-contribution/ travel-contribution/META-INF/ travel-contribution/src/ travel-contribution/src/scatours/ travel-contribution/src/scatours/travel/ trip-contribution/src/s...

Author: slaws
Date: Sun Aug 10 08:15:28 2008
New Revision: 684518

URL: http://svn.apache.org/viewvc?rev=684518&view=rev
Log:
Separate the search into a travel component so that it is independent of the trip booking

Added:
    tuscany/sandbox/travelsample/travel-contribution/   (with props)
    tuscany/sandbox/travelsample/travel-contribution/META-INF/
    tuscany/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml   (with props)
    tuscany/sandbox/travelsample/travel-contribution/pom.xml   (with props)
    tuscany/sandbox/travelsample/travel-contribution/src/
    tuscany/sandbox/travelsample/travel-contribution/src/scatours/
    tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/
    tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java   (with props)
    tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java   (with props)
    tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java   (with props)
    tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java
      - copied, changed from r684215, tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java
Removed:
    tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java
    tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java
Modified:
    tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java
    tuscany/sandbox/travelsample/pom.xml
    tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
    tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
    tuscany/sandbox/travelsample/ui-contribution/build.xml
    tuscany/sandbox/travelsample/ui-contribution/scatours.composite
    tuscany/sandbox/travelsample/ui-contribution/scatours.html

Modified: tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java?rev=684518&r1=684517&r2=684518&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java (original)
+++ tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java Sun Aug 10 08:15:28 2008
@@ -43,6 +43,7 @@
                                                                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("ui", "../ui-contribution/target/scatours-ui-contribution.jar"));
 
             node.start();
@@ -71,6 +72,7 @@
                                                                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("ui", "../ui-contribution/target/classes"));
             node.start();
             

Modified: tuscany/sandbox/travelsample/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/pom.xml?rev=684518&r1=684517&r2=684518&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/pom.xml (original)
+++ tuscany/sandbox/travelsample/pom.xml Sun Aug 10 08:15:28 2008
@@ -44,6 +44,7 @@
                 <module>car-contribution</module>
                 <module>payment-contribution</module>
                 <module>trip-contribution</module>
+                <module>travel-contribution</module>
                 <module>ui-contribution</module>
 
                 <module>domain</module>

Propchange: tuscany/sandbox/travelsample/travel-contribution/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Aug 10 08:15:28 2008
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target

Added: tuscany/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml?rev=684518&view=auto
==============================================================================
--- tuscany/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml (added)
+++ tuscany/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml Sun Aug 10 08:15:28 2008
@@ -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.trip"/>
+   <export.java package="scatours.travel"/>
+</contribution>
\ No newline at end of file

Propchange: tuscany/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: tuscany/sandbox/travelsample/travel-contribution/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/travel-contribution/pom.xml?rev=684518&view=auto
==============================================================================
--- tuscany/sandbox/travelsample/travel-contribution/pom.xml (added)
+++ tuscany/sandbox/travelsample/travel-contribution/pom.xml Sun Aug 10 08:15:28 2008
@@ -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-travel-contribution</artifactId>
+    <name>Apache Tuscany SCA Tours Travel 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.2</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>

Propchange: tuscany/sandbox/travelsample/travel-contribution/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/travelsample/travel-contribution/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/sandbox/travelsample/travel-contribution/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java?rev=684518&view=auto
==============================================================================
--- tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java (added)
+++ tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java Sun Aug 10 08:15:28 2008
@@ -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.travel;
+
+
+import org.osoa.sca.annotations.Remotable;
+
+import scatours.common.TripItem;
+
+/**
+ * The TravelBooking service interface
+ */
+@Remotable
+public interface TravelBooking {
+       
+    void addTripItem(String id);
+    void removeTripItem(String id);
+    double getTotalPrice();
+    void purchaseTrip();
+}

Propchange: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java?rev=684518&view=auto
==============================================================================
--- tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java (added)
+++ tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java Sun Aug 10 08:15:28 2008
@@ -0,0 +1,151 @@
+/*
+ * 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.ComponentContext;
+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,ServiceReference<Trip>> trips = new HashMap<String,ServiceReference<Trip>>();
+    
+    // TravelSearch methods
+    
+    public TripItem[] search(TripLeg tripLeg) {
+        
+        searchResults.clear();
+        responsesReceived = 0;
+        
+        hotelSearch.searchAsynch(tripLeg);
+        flightSearch.searchAsynch(tripLeg);
+        carSearch.searchAsynch(tripLeg);
+        
+        while (responsesReceived < 3){
+            try {
+                this.wait();
+            } catch (InterruptedException ex){
+                // do nothing
+            }
+        }
+        
+        for (TripItem tripItem : searchResults){
+            tripItem.setId(UUID.randomUUID().toString());
+            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){
+        for(int i = 0; i < items.length; i++ ){
+            searchResults.add(items[i]);
+        }
+        
+        responsesReceived++;
+        try {
+            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);
+        return tripId;
+    }
+    
+    public void addTripItem(String id){
+        for (TripItem tripItem : searchResults) {
+            if (tripItem.getId().equals(id)){
+                trip.addTripItem(tripItem);
+            }
+        }
+    }
+    
+    public void removeTripItem(String id){
+        trip.removeTripItem(id);
+    }     
+    
+    public double getTotalPrice(){ 
+        return trip.getTripPrice();
+    }
+    
+    public void purchaseTrip() {
+        trip.purchaseTrip();
+    }
+}

Propchange: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java?rev=684518&view=auto
==============================================================================
--- tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java (added)
+++ tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java Sun Aug 10 08:15:28 2008
@@ -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);
+}

Propchange: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java (from r684215, tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java)
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java?p2=tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java&p1=tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java&r1=684215&r2=684518&rev=684518&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java (original)
+++ tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java Sun Aug 10 08:15:28 2008
@@ -18,7 +18,10 @@
  */
 package scatours.trip;
 
-import org.apache.tuscany.sca.data.collection.Collection;
+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;
@@ -27,9 +30,17 @@
  * The Trip service interface
  */
 @Remotable
-public interface TripContents extends Collection<String, TripItem> {
+@Conversational
+public interface Trip {
+       
+    void startTrip(String id);
+
+    void addTripItem(TripItem tripItem);
     
-    void addTripItem(String id);
     void removeTripItem(String id);
-    double getTotalPrice();
+    
+    double getTripPrice();
+    
+    @EndsConversation
+    void purchaseTrip();
 }

Modified: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java?rev=684518&r1=684517&r2=684518&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java (original)
+++ tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java Sun Aug 10 08:15:28 2008
@@ -18,169 +18,59 @@
  */
 package scatours.trip;
 
-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.annotations.Property;
-import org.osoa.sca.annotations.Reference;
+
+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.Search;
-import scatours.common.SearchCallback;
+
 import scatours.common.TripItem;
-import scatours.common.TripLeg;
-import scatours.currencyconverter.CurrencyConverter;
 
 /**
  * An implementation of the Trip service
  */
-@Scope("COMPOSITE")
-@Service(interfaces={TripSearch.class, TripContents.class})
-public class TripImpl implements TripSearch, SearchCallback, TripContents{
-    
-    @Reference
-    protected CurrencyConverter currencyConverter;
-    
-    @Reference 
-    protected Search hotelSearch;
-    
-    @Reference 
-    protected Search flightSearch;
-    
-    @Reference 
-    protected Search carSearch;
-        
-    @Property
-    public String quoteCurrencyCode = "USD";
-    
-    private int responsesReceived = 0;
+@Scope("CONVERSATION")
+@Service(interfaces={Trip.class})
+public class TripImpl implements Trip{
+
+    @ConversationID
+    protected String conversationId;
     
-    private List<TripItem> searchResults = new ArrayList<TripItem>();
     private Map<String, TripItem> tripItems = new HashMap<String, TripItem>();
+     
+    // Trip methods
     
-    // TripSearch methods
+    @Init
+    public void initTrip() {
+        //TODO
+        System.out.println("Trip init");
+    }
     
-    public TripItem[] search(TripLeg tripLeg) {
-        
-        searchResults.clear();
-        responsesReceived = 0;
-        
-        hotelSearch.searchAsynch(tripLeg);
-        flightSearch.searchAsynch(tripLeg);
-        carSearch.searchAsynch(tripLeg);
-        
-        while (responsesReceived < 3){
-            try {
-                this.wait();
-            } catch (InterruptedException ex){
-                // do nothing
-            }
-        }
-        
-        for (TripItem tripItem : searchResults){
-            tripItem.setId(UUID.randomUUID().toString());
-            tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(), 
-                                                        quoteCurrencyCode, 
-                                                        tripItem.getPrice()));
-            tripItem.setCurrency(quoteCurrencyCode);
-        }
-        
-        return searchResults.toArray(new TripItem[searchResults.size()]);
+    @Destroy
+    public void destroyTrip() {
+        //TODO
+        System.out.println("Trip destroy");
     }
     
-    // SearchCallback methods
+    public void startTrip(String id){
+        tripItems.clear();
+    }
     
-    public void searchResults(TripItem[] items){
-        for(int i = 0; i < items.length; i++ ){
-            searchResults.add(items[i]);
-        }
-        
-        responsesReceived++;
-        try {
-            this.notifyAll();
-        } catch (Exception ex) {
-        }
-    }    
-
-    // TripContents methods
-    public void addTripItem(String id){
-        for (TripItem tripItem : searchResults) {
-            if (tripItem.getId().equals(id)){
-                tripItems.put(id, tripItem);
-            }
-        }
+    public void addTripItem(TripItem tripItem){
+        tripItems.put(tripItem.getId(), tripItem);
     }
     
     public void removeTripItem(String id){
         tripItems.remove(id);
     }     
     
-    // Not using the DataCollection iface yet as it seems like a 
-    // likely attach vector to be passing complete tripItem records in
-    // really need to look up the cached item based on id    
-    public Entry<String, TripItem>[] getAll() {
-        Entry<String, TripItem>[] entries = new Entry[tripItems.size()];
-        int i = 0;
-        for (Map.Entry<String, TripItem> e: tripItems.entrySet()) {
-            entries[i++] = new Entry<String, TripItem>(e.getKey(), e.getValue());
-        }
-        return entries;
-    }
-    
-    public TripItem get(String key) throws NotFoundException {
-        TripItem item = tripItems.get(key);
-        if (item == null) {
-            throw new NotFoundException(key);
-        } else {
-            return item;
-        }
-    }
-
-    public String post(String key, TripItem item) {
-        tripItems.put(key, item);
-        return key;
-    }
-
-    public void put(String key, TripItem item) throws NotFoundException {
-        if (!tripItems.containsKey(key)) {
-            throw new NotFoundException(key);
-        }
-        tripItems.put(key, item);
-    }
-    
-    public void delete(String key) throws NotFoundException {
-        if (key == null || key.equals("")) {
-            tripItems.clear();
-        } else {
-            TripItem item = tripItems.remove(key);
-            if (item == null)
-                throw new NotFoundException(key);
-        }
-    }
-
-    public Entry<String, TripItem>[] query(String queryString) {
-        List<Entry<String, TripItem>> entries = new ArrayList<Entry<String,TripItem>>();
-        if (queryString.startsWith("name=")) {
-            String name = queryString.substring(5);
-            for (Map.Entry<String, TripItem> e: tripItems.entrySet()) {
-                TripItem item = e.getValue();
-                if (item.getName().equals(name)) {
-                    entries.add(new Entry<String, TripItem>(e.getKey(), e.getValue()));
-                }
-            }
-        }
-        return entries.toArray(new Entry[entries.size()]);
-    }
-   
-    // TripTotal methods
-    
-    public double getTotalPrice(){ 
+    public double getTripPrice(){ 
         double totalPrice = 0.0;
         
         for (TripItem tripItem : tripItems.values()){
@@ -190,5 +80,7 @@
         return totalPrice;
     }
     
-
+    public void purchaseTrip() {
+        // TODO
+    }
 }

Modified: tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml?rev=684518&r1=684517&r2=684518&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml (original)
+++ tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml Sun Aug 10 08:15:28 2008
@@ -25,5 +25,6 @@
    <import.java package="scatours.flight"/>
    <import.java package="scatours.car"/>
    <import.java package="scatours.trip"/>
+   <import.java package="scatours.travel"/>
    <deployable composite="scatours:scatours"/>
 </contribution>
\ No newline at end of file

Modified: tuscany/sandbox/travelsample/ui-contribution/build.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/ui-contribution/build.xml?rev=684518&r1=684517&r2=684518&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/ui-contribution/build.xml (original)
+++ tuscany/sandbox/travelsample/ui-contribution/build.xml Sun Aug 10 08:15:28 2008
@@ -100,7 +100,6 @@
         <include name="jsr250-api-1.0.jar"/>
         <include name="stax-api-1.0-2.jar"/>
         <include name="wstx-asl-3.2.1.jar"/>
-        <include name="xml-apis-1.3.03.jar"/>
     </fileset>
 
 </project>

Modified: tuscany/sandbox/travelsample/ui-contribution/scatours.composite
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/ui-contribution/scatours.composite?rev=684518&r1=684517&r2=684518&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/ui-contribution/scatours.composite (original)
+++ tuscany/sandbox/travelsample/ui-contribution/scatours.composite Sun Aug 10 08:15:28 2008
@@ -37,23 +37,23 @@
         <reference name="car" target="CarComponent">
             <tuscany:binding.jsonrpc/>
         </reference>
-        <reference name="tripSearch" target="TripComponent/TripSearch">
+        <reference name="travelSearch" target="TravelComponent/TravelSearch">
             <tuscany:binding.jsonrpc/>
         </reference>
-        <reference name="tripContents" target="TripComponent/TripContents">
+        <reference name="travelBooking" target="TravelComponent/TravelBooking">
             <tuscany:binding.jsonrpc/>
         </reference>  
     </component>
     
-    <component name="TripComponent">
-        <implementation.java class="scatours.trip.TripImpl"/>
-        <service name="TripSearch">
+    <component name="TravelComponent">
+        <implementation.java class="scatours.travel.TravelImpl"/>
+        <service name="TravelSearch">
             <tuscany:binding.jsonrpc/>
         </service>
-        <service name="TripContents">
+        <service name="TravelBooking">
             <tuscany:binding.jsonrpc/>
         </service>
-        <reference name="hotelSearch" target="HotelComponent">
+        <reference name="hotelSearch" target="HotelComponent/Search">
             <binding.sca/>
         </reference>
         <reference name="flightSearch" target="FlightComponent">
@@ -64,8 +64,15 @@
         </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>    
         
     <component name="HotelComponent">
         <implementation.java class="scatours.hotel.HotelImpl"/>

Modified: tuscany/sandbox/travelsample/ui-contribution/scatours.html
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/ui-contribution/scatours.html?rev=684518&r1=684517&r2=684518&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/ui-contribution/scatours.html (original)
+++ tuscany/sandbox/travelsample/ui-contribution/scatours.html Sun Aug 10 08:15:28 2008
@@ -36,10 +36,10 @@
     var car = new Reference("car");    
 	
     //@Reference
-    var tripSearch = new Reference("tripSearch");
+    var travelSearch = new Reference("travelSearch");
     
     //@Reference
-    var tripContents = new Reference("tripContents");
+    var travelBooking = new Reference("travelBooking");
         
     //local state
     var searchResponseItems;
@@ -62,11 +62,11 @@
     
     function getTripLeg(){
         return new TripLegType("X",
-                               document.searchForm.fromLocation.value,
-                               document.searchForm.toLocation.value,
-                               document.searchForm.fromDate.value,
-                               document.searchForm.toDate.value,
-                               document.searchForm.noOfPeople.value);
+                               document.travelForm.fromLocation.value,
+                               document.travelForm.toLocation.value,
+                               document.travelForm.fromDate.value,
+                               document.travelForm.toDate.value,
+                               document.travelForm.noOfPeople.value);
     }
 		
     function init() {
@@ -90,8 +90,8 @@
         car.searchSynch(getTripLeg(), search_response);
     } 
         
-    function searchTrip() {        
-        tripSearch.search(getTripLeg(), search_response);
+    function searchPackages() {        
+        travelSearch.search(getTripLeg(), search_response);
     }
         
     function search_response(items, exception) {
@@ -127,13 +127,13 @@
         var j = 0;
         for (var i=0; i<items.length; i++) {
             if (items[i].checked == true) {
-                tripContents.addTripItem(items[i].value);
+                travelBooking.addTripItem(items[i].value);
             } else {
-                tripContents.removeTripItem(items[i].value);
+                travelBooking.removeTripItem(items[i].value);
             }
         }
         
-        tripContents.getTotalPrice(totalPrice_response);
+        travelBooking.getTotalPrice(totalPrice_response);
     }    
     
     function totalPrice_response(totalPrice, exception) {
@@ -143,6 +143,19 @@
         }
         document.getElementById('totalPrice').innerHTML = totalPrice;
     }
+    
+    function newTrip() { 
+    
+    }
+    
+    function purchaseTrip() {        
+        travelBooking.purchaseTrip();
+        
+        document.getElementById('tripItems').innerHTML = "Thank you for shopping with SCA Tours";
+        document.getElementById('totalPrice').innerHTML = "";
+        searchResponseItems = null;
+        tripItems = null;
+    }    
 	
 </script>
 
@@ -152,7 +165,7 @@
 	<img src="scatours.png" border="0" />
 	<div id="scatours">
         <br>
-        <form name="searchForm">   
+        <form name="travelForm">   
             <table border="0">
                 <tr>
                     <td>From Location:</td>
@@ -178,18 +191,21 @@
                     <td/>
                 </tr>
             </table>
+            <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="searchHotels()" value="Search Cars"> 
-            <br/>
-            <input type="button" onClick="searchTrip()" value="SearchTrip"> 
         </form>
         <form name="tripForm"> 
             <div id="searchResponse"></div>
-            <br>  
+            <br> 
+            <input type="button" onClick="newTrip()" value="Create New Trip">  
+            <br>
             <div id="totalPrice"></div>
             <br>
-            <input type="button" onClick="bookTrip()" value="Book Trip"> 
+            <div id="tripItems"></div>
+            <br>
+            <input type="button" onClick="purchaseTrip()" value="Purchase Trip"> 
         </form>