diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-14 15:45:33 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-14 15:45:33 +0000 |
commit | 6222ba67f2fd06e34dde842a82e553d3280acaaa (patch) | |
tree | 5ebf9d891df80d8b5fb46ab62655543048a38b9b | |
parent | f7cdb52f0e6c981a78eb4c9c4787688023685b8f (diff) |
Extend the launcher for the interaction examples based on components from the travel sample
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@784575 13f79535-47bb-0310-9956-ffa450edef68
22 files changed, 409 insertions, 151 deletions
diff --git a/sandbox/travelsample/contributions/car-contribution/src/main/java/scatours/car/CarImpl.java b/sandbox/travelsample/contributions/car-contribution/src/main/java/scatours/car/CarImpl.java index 2ed94333d7..04742446ed 100644 --- a/sandbox/travelsample/contributions/car-contribution/src/main/java/scatours/car/CarImpl.java +++ b/sandbox/travelsample/contributions/car-contribution/src/main/java/scatours/car/CarImpl.java @@ -92,7 +92,7 @@ public class CarImpl implements Search, Book { System.out.println("Starting car search");
try {
- this.wait(4000);
+ Thread.sleep(4000);
} catch(Exception ex){
// do nothing
}
@@ -101,7 +101,11 @@ public class CarImpl implements Search, Book { searchCallback.searchResults(searchSynch(tripLeg));
}
+ public int getPercentComplete(){
+ return 100;
+ }
+
public String book(TripItem tripItem) {
return "car1";
- }
+ }
}
diff --git a/sandbox/travelsample/contributions/common-contribution/src/main/java/scatours/common/Search.java b/sandbox/travelsample/contributions/common-contribution/src/main/java/scatours/common/Search.java index 020d09a0ae..097ae69e38 100644 --- a/sandbox/travelsample/contributions/common-contribution/src/main/java/scatours/common/Search.java +++ b/sandbox/travelsample/contributions/common-contribution/src/main/java/scatours/common/Search.java @@ -20,14 +20,18 @@ package scatours.common;
import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Conversational;
import org.osoa.sca.annotations.OneWay;
import org.osoa.sca.annotations.Remotable;
@Remotable
+@Conversational
@Callback(SearchCallback.class)
public interface Search {
TripItem[] searchSynch(TripLeg tripLeg);
@OneWay
void searchAsynch(TripLeg tripLeg);
+
+ int getPercentComplete();
}
diff --git a/sandbox/travelsample/contributions/common-contribution/src/main/java/scatours/common/SearchCallback.java b/sandbox/travelsample/contributions/common-contribution/src/main/java/scatours/common/SearchCallback.java index 3f94b29676..252fb955a2 100644 --- a/sandbox/travelsample/contributions/common-contribution/src/main/java/scatours/common/SearchCallback.java +++ b/sandbox/travelsample/contributions/common-contribution/src/main/java/scatours/common/SearchCallback.java @@ -19,9 +19,14 @@ package scatours.common;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
import org.osoa.sca.annotations.Remotable;
@Remotable
+@Conversational
public interface SearchCallback {
+ @EndsConversation
void searchResults(TripItem[] items);
+ void setPercentComplete(String searchComponent, int percentComplete);
}
diff --git a/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightImpl.java b/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightImpl.java index e2f945b392..307c740ca1 100644 --- a/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightImpl.java +++ b/sandbox/travelsample/contributions/flight-contribution/src/main/java/scatours/flight/FlightImpl.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List;
import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.ComponentName;
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;
@@ -35,7 +36,7 @@ import scatours.common.TripLeg; /**
* An implementation of the Hotel service
*/
-@Scope("STATELESS")
+@Scope("CONVERSATION")
@Service(interfaces={Search.class, Book.class})
public class FlightImpl implements Search, Book {
@@ -43,6 +44,11 @@ public class FlightImpl implements Search, Book { @Callback
protected SearchCallback searchCallback;
+
+ @ComponentName
+ protected String componentName;
+
+ protected int percentComplete = 0;
@Init
public void init() {
@@ -118,16 +124,25 @@ public class FlightImpl implements Search, Book { public void searchAsynch(TripLeg tripLeg) {
System.out.println("Starting flight search");
- try {
- this.wait(3000);
- } catch(Exception ex){
- // do nothing
+ // pretend that this processing takes some time to complete
+ while ( percentComplete < 100 ){
+ try {
+ Thread.sleep(50);
+ } catch(Exception ex){
+ // do nothing
+ }
+ percentComplete = percentComplete + 10;
+ searchCallback.setPercentComplete(componentName, percentComplete);
}
- // return available hotels
+ // return available flights
searchCallback.searchResults(searchSynch(tripLeg));
}
+ public int getPercentComplete(){
+ return 100;
+ }
+
public String book(TripItem tripItem) {
return "flight1";
}
diff --git a/sandbox/travelsample/contributions/hotel-contribution/src/main/java/scatours/hotel/HotelImpl.java b/sandbox/travelsample/contributions/hotel-contribution/src/main/java/scatours/hotel/HotelImpl.java index 7109bd3d2e..8b50d0fd6b 100644 --- a/sandbox/travelsample/contributions/hotel-contribution/src/main/java/scatours/hotel/HotelImpl.java +++ b/sandbox/travelsample/contributions/hotel-contribution/src/main/java/scatours/hotel/HotelImpl.java @@ -107,16 +107,21 @@ public class HotelImpl implements Search, Book, HotelManagement { public void searchAsynch(TripLeg tripLeg) {
System.out.println("Starting hotel search");
- try {
- this.wait(1000);
- } catch(Exception ex){
- // do nothing
+ // pretend that this processing takes some time to complete
+ try {
+ Thread.sleep(3000);
+ } catch(Exception ex){
+ // do nothing
}
// return available hotels
searchCallback.searchResults(searchSynch(tripLeg));
}
+ public int getPercentComplete(){
+ return 100;
+ }
+
public String book(TripItem tripItem) {
return "hotel1";
}
diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/pom.xml b/sandbox/travelsample/contributions/interaction-client-contribution/pom.xml index 920c0d01c1..052475f3f7 100644 --- a/sandbox/travelsample/contributions/interaction-client-contribution/pom.xml +++ b/sandbox/travelsample/contributions/interaction-client-contribution/pom.xml @@ -58,6 +58,12 @@ <artifactId>scatours-currency-contribution</artifactId> <version>1.0-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>scatours-shoppingcart-contribution</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> </dependencies> <build> diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionClient.java b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionClient.java deleted file mode 100644 index 9953d4b1a5..0000000000 --- a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionClient.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.client; - -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Service; - -import calendar.Calendar; - -import scatours.common.Search; -import scatours.common.SearchCallback; -import scatours.common.TripItem; -import scatours.common.TripLeg; - -@Service(Runnable.class) -public class InteractionClient implements Runnable, SearchCallback { - @Reference - protected Search hotelSearchRemoteRequestResponse; - - @Reference - protected Calendar calendarLocalRequestResponse; - - public InteractionClient() { - } - - // Runnable method - - public void run() { - System.out.println("Calling hotel component over remote binding"); - runRemoteRequestResponse(); - - System.out.println("Calling calendar component over local binding"); - runLocalRequestReponse(); - } - - private void runRemoteRequestResponse() { - TripLeg tripLeg = getTestTripLeg(); - TripItem[] tripItems = hotelSearchRemoteRequestResponse.searchSynch(tripLeg); - for (TripItem tripItem : tripItems){ - System.out.println("Found hotel - " + tripItem.getName()); - } - } - - private void runLocalRequestReponse() { - TripLeg tripLeg = getTestTripLeg(); - String toDate = calendarLocalRequestResponse.getEndDate(tripLeg.getFromDate(), 10); - tripLeg.setToDate(toDate); - System.out.println("Calculated trip end date - " + toDate); - } - - private void runRemoteOneWay() { - - } - - private void runConversational() { - - } - - private void runCallback() { - - } - - private void runStatefulCallback() { - - } - - private TripLeg getTestTripLeg(){ - TripLeg tripLeg = new TripLeg(); - tripLeg.setFromLocation("LGW"); - tripLeg.setToLocation("FLR"); - tripLeg.setFromDate("06/12/09 00:00"); - tripLeg.setToDate("13/12/09 00:00"); - tripLeg.setNoOfPeople("1"); - tripLeg.setId("TRIP27"); - - return tripLeg; - } - - // SearchCallback methods - - public void searchResults(TripItem[] items){ -/* - RequestContext requestContext = componentContext.getRequestContext(); - Object callbackID = requestContext.getServiceReference().getCallbackID(); - System.out.println(callbackID); - - if (items != null) { - 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/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionConversationClient.java b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionConversationClient.java new file mode 100644 index 0000000000..c013cd63fb --- /dev/null +++ b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionConversationClient.java @@ -0,0 +1,78 @@ +/* + * 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.client; + +import java.util.concurrent.CountDownLatch; + +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.shoppingcart.CartStore; + +@Scope("COMPOSITE") +@Service(Runnable.class) +public class InteractionConversationClient implements Runnable{ + + @Reference + protected CartStore cartStoreConversation; + + public void run() { + System.out.println("\nCalling cart store using the conversational interaction pattern"); + + // add some trip items to the cart store + TripItem tripItem = getTestTripItem(); + cartStoreConversation.addTrip(tripItem); + + tripItem.setDescription("2nd trip item"); + cartStoreConversation.addTrip(tripItem); + + tripItem.setDescription("3rd trip item"); + cartStoreConversation.addTrip(tripItem); + + System.out.println("Trip items now in cart"); + TripItem[] tripItems = cartStoreConversation.getTrips(); + for (TripItem item : tripItems){ + System.out.println("Item - " + item.getDescription()); + } + + System.out.println("Reset the cart"); + cartStoreConversation.reset(); + + System.out.println("Trip items now in cart"); + tripItems = cartStoreConversation.getTrips(); + for (TripItem item : tripItems){ + System.out.println("Item - " + item.getDescription()); + } + } + + private TripItem getTestTripItem(){ + TripItem tripItem = new TripItem(); + tripItem.setLocation("FLR"); + tripItem.setFromDate("06/12/09 00:00"); + tripItem.setToDate("13/12/09 00:00"); + tripItem.setDescription("1st trip item"); + return tripItem; + } +} diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionLocalClient.java b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionLocalClient.java index fb1a7c29d5..4ada5ab47f 100644 --- a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionLocalClient.java +++ b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionLocalClient.java @@ -33,7 +33,7 @@ public class InteractionLocalClient implements Runnable { protected Calendar calendarLocal; public void run() { - System.out.println("\nCalling calendar component over local binding"); + System.out.println("\nCalling calendar component over a local binding"); TripLeg tripLeg = getTestTripLeg(); String toDate = calendarLocal.getEndDate(tripLeg.getFromDate(), 10); tripLeg.setToDate(toDate); diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionOneWayCallbackClient.java b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionOneWayCallbackClient.java new file mode 100644 index 0000000000..94ef5ef284 --- /dev/null +++ b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionOneWayCallbackClient.java @@ -0,0 +1,78 @@ +/* + * 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.client; + +import java.util.concurrent.CountDownLatch; + +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; + +@Scope("COMPOSITE") +@Service(Runnable.class) +public class InteractionOneWayCallbackClient implements Runnable, SearchCallback{ + + @Reference + protected Search hotelSearchOneWayCallback; + + CountDownLatch resultsReceivedCountdown; + + public void run() { + System.out.println("\nCalling hotel component using both one way and callback interation patterns"); + resultsReceivedCountdown = new CountDownLatch(1); + TripLeg tripLeg = getTestTripLeg(); + hotelSearchOneWayCallback.searchAsynch(tripLeg); + + // start other searched here while the hotel search progresses + + // wait for responses to come back + try { + resultsReceivedCountdown.await(); + } catch (InterruptedException ex){ + } + } + + public void searchResults(TripItem[] items){ + for (TripItem tripItem : items){ + System.out.println("Found hotel - " + tripItem.getName()); + } + resultsReceivedCountdown.countDown(); + } + + public void setPercentComplete(String searchComponent, int percentComplete){ + // Not used in this sample + } + + private TripLeg getTestTripLeg(){ + TripLeg tripLeg = new TripLeg(); + tripLeg.setFromLocation("LGW"); + tripLeg.setToLocation("FLR"); + tripLeg.setFromDate("06/12/09 00:00"); + tripLeg.setToDate("13/12/09 00:00"); + tripLeg.setNoOfPeople("1"); + tripLeg.setId("TRIP27"); + return tripLeg; + } +} diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionRemoteClient.java b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionRemoteClient.java index 2f198797a1..278c7bb08f 100644 --- a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionRemoteClient.java +++ b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionRemoteClient.java @@ -34,7 +34,7 @@ public class InteractionRemoteClient implements Runnable, SearchCallback{ protected Search hotelSearchRemote; public void run() { - System.out.println("\nCalling hotel component over remote binding"); + System.out.println("\nCalling hotel component over a remote binding"); TripLeg tripLeg = getTestTripLeg(); TripItem[] tripItems = hotelSearchRemote.searchSynch(tripLeg); for (TripItem tripItem : tripItems){ @@ -47,6 +47,10 @@ public class InteractionRemoteClient implements Runnable, SearchCallback{ // so the callback interface is not used } + public void setPercentComplete(String searchComponent, int percentComplete){ + // Not used in this sample + } + private TripLeg getTestTripLeg(){ TripLeg tripLeg = new TripLeg(); tripLeg.setFromLocation("LGW"); diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionRequestResponseClient.java b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionRequestResponseClient.java index 20cb8fd740..0ca001fd9b 100644 --- a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionRequestResponseClient.java +++ b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionRequestResponseClient.java @@ -34,7 +34,7 @@ public class InteractionRequestResponseClient implements Runnable { protected CurrencyConverter currencyConverterRequestResponse; public void run() { - System.out.println("\nCalling currency converter component using request response pattern"); + System.out.println("\nCalling currency converter component using request response interation pattern"); double convertedAmount = currencyConverterRequestResponse.convert("GBP", "USD", 10.0); System.out.println("10 GBP = " + convertedAmount + " USD"); } diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionStatefulCallbackClient.java b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionStatefulCallbackClient.java new file mode 100644 index 0000000000..690c99373e --- /dev/null +++ b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/java/scatours/client/InteractionStatefulCallbackClient.java @@ -0,0 +1,98 @@ +/* + * 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.client; + +import java.util.concurrent.CountDownLatch; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.ConversationID; +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; + +@Scope("CONVERSATION") +@Service(Runnable.class) +public class InteractionStatefulCallbackClient implements Runnable, SearchCallback{ + + @Reference + protected Search flightSearchStatefulCallback; + + @Context + protected ComponentContext componentContext; + + CountDownLatch resultsReceivedCountdown; + + public void run() { + System.out.println("\nCalling flight component using stateful callback interation pattern"); + resultsReceivedCountdown = new CountDownLatch(1); + TripLeg tripLeg = getTestTripLeg(); + + ServiceReference<Search> dynamicFlightSearchStatefulCallback = + componentContext.getServiceReference(Search.class, "flightSearchStatefulCallback"); + dynamicFlightSearchStatefulCallback.setConversationID("SomeUniqeID"); + Search flightSearch = dynamicFlightSearchStatefulCallback.getService(); + + flightSearch.searchAsynch(tripLeg); + + // wait for a while and see how the flight search is getting one + try { + Thread.sleep(1200); + } catch(Exception ex){ + // do nothing + } + System.out.println("Flight search is " + flightSearch.getPercentComplete() + "% complete"); + + // wait for responses to come back + try { + resultsReceivedCountdown.await(); + } catch (InterruptedException ex){ + } + } + + public void searchResults(TripItem[] items){ + System.out.println("Received results in conversation - " + componentContext.getRequestContext().getServiceReference().getConversation().getConversationID()); + for (TripItem tripItem : items){ + System.out.println("Found flight - " + tripItem.getName()); + } + resultsReceivedCountdown.countDown(); + } + + public void setPercentComplete(String searchComponent, int percentComplete){ + System.out.println(searchComponent + " search is " + percentComplete + "% complete"); + } + + private TripLeg getTestTripLeg(){ + TripLeg tripLeg = new TripLeg(); + tripLeg.setFromLocation("LGW"); + tripLeg.setToLocation("FLR"); + tripLeg.setFromDate("06/12/09"); + tripLeg.setToDate("13/12/09"); + tripLeg.setNoOfPeople("1"); + tripLeg.setId("TRIP27"); + return tripLeg; + } +} diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/resources/META-INF/sca-contribution.xml index 848e0bea5b..bc47b4de2e 100644 --- a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/resources/META-INF/sca-contribution.xml +++ b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -22,5 +22,6 @@ <import.java package="calendar"/> <import.java package="scatours.common"/> <import.java package="scatours.currencyconverter"/> + <import.java package="scatours.shoppingcart"/> <deployable composite="client:Client" /> </contribution> diff --git a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/resources/client.composite b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/resources/client.composite index c2ff2c9a89..f6483bb55f 100644 --- a/sandbox/travelsample/contributions/interaction-client-contribution/src/main/resources/client.composite +++ b/sandbox/travelsample/contributions/interaction-client-contribution/src/main/resources/client.composite @@ -21,7 +21,7 @@ targetNamespace="http://client.scatours/" name="Client"> - <!-- Local interaction --> + <!-- Local interaction --> <component name="InteractionLocalClient"> <implementation.java class="scatours.client.InteractionLocalClient" /> <reference name="calendarLocal" @@ -32,22 +32,59 @@ <implementation.java class="calendar.CalendarImpl"/> </component> - <!-- Remote interaction --> + <!-- Remote interaction --> <component name="InteractionRemoteClient"> <implementation.java class="scatours.client.InteractionRemoteClient" /> <reference name="hotelSearchRemote"> - <binding.ws uri="http://localhost:8081/HotelComponent/Search"/> + <binding.ws uri="http://localhost:8081/Hotel/Search"/> </reference> - </component> + </component> - <!-- Request response interaction --> - <component name="InteractionRequestResponseClient"> + <!-- Request response interaction --> + <component name="InteractionRequestResponseClient"> <implementation.java class="scatours.client.InteractionRequestResponseClient" /> - <reference name="currencyConverterRequestResponse" target="CurrencyConverterComponent"/> - </component> + <reference name="currencyConverterRequestResponse" target="CurrencyConverter"/> + </component> - <component name="CurrencyConverterComponent"> + <component name="CurrencyConverter"> <implementation.java class="scatours.currencyconverter.CurrencyConverterImpl"/> - </component> + </component> + + <!-- One way and callback interaction --> + <component name="InteractionOneWayCallbackClient"> + <implementation.java class="scatours.client.InteractionOneWayCallbackClient" /> + <reference name="hotelSearchOneWayCallback"> + <interface.java interface="scatours.common.Search" + callbackInterface="scatours.common.SearchCallback"/> + <binding.ws uri="http://localhost:8081/Hotel/Search"/> + <callback> + <binding.ws uri="http://localhost:8080/Client/SearchCallback"/> + </callback> + </reference> + </component> + + <!-- Conversational interaction --> + <component name="InteractionConversationClient"> + <implementation.java class="scatours.client.InteractionConversationClient" /> + <reference name="cartStoreConversation" target="CartStore"/> + </component> + + <component name="CartStore"> + <implementation.java class="scatours.shoppingcart.CartStoreImpl"/> + <service name="CartStore"/> + </component> + + <!-- Stateful callback interaction --> + <component name="InteractionStatefulCallbackClient"> + <implementation.java class="scatours.client.InteractionStatefulCallbackClient" /> + <reference name="flightSearchStatefulCallback"> + <interface.java interface="scatours.common.Search" + callbackInterface="scatours.common.SearchCallback"/> + <binding.ws uri="http://localhost:8081/Hotel/SearchConversational"/> + <callback> + <binding.ws uri="http://localhost:8080/Client/SearchCallbackConversational"/> + </callback> + </reference> + </component> </composite> diff --git a/sandbox/travelsample/contributions/interaction-service-remote-contribution/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contributions/interaction-service-remote-contribution/src/main/resources/META-INF/sca-contribution.xml index 26a786065e..716264650c 100644 --- a/sandbox/travelsample/contributions/interaction-service-remote-contribution/src/main/resources/META-INF/sca-contribution.xml +++ b/sandbox/travelsample/contributions/interaction-service-remote-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -21,5 +21,6 @@ xmlns:client="http://client.scatours/"> <import.java package="scatours.common"/> <import.java package="scatours.hotel"/> + <import.java package="scatours.flight"/> <deployable composite="client:Client" /> </contribution> diff --git a/sandbox/travelsample/contributions/interaction-service-remote-contribution/src/main/resources/client.composite b/sandbox/travelsample/contributions/interaction-service-remote-contribution/src/main/resources/client.composite index 36ce4392a9..4c693864bb 100644 --- a/sandbox/travelsample/contributions/interaction-service-remote-contribution/src/main/resources/client.composite +++ b/sandbox/travelsample/contributions/interaction-service-remote-contribution/src/main/resources/client.composite @@ -21,11 +21,28 @@ targetNamespace="http://service.scatours/" name="Service"> - <component name="HotelComponent"> + <component name="Hotel"> <implementation.java class="scatours.hotel.HotelImpl"/> <service name="Search"> - <binding.ws uri="http://localhost:8081/HotelComponent/Search"/> + <interface.java interface="scatours.common.Search" + callbackInterface="scatours.common.SearchCallback"/> + <binding.ws uri="http://localhost:8081/Hotel/Search"/> + <callback> + <binding.ws uri="http://localhost:8080/Client/SearchCallback"/> + </callback> </service> </component> + + <component name="Flight"> + <implementation.java class="scatours.flight.FlightImpl"/> + <service name="Search"> + <interface.java interface="scatours.common.Search" + callbackInterface="scatours.common.SearchCallback"/> + <binding.ws uri="http://localhost:8081/Hotel/SearchConversational"/> + <callback> + <binding.ws uri="http://localhost:8080/Client/SearchCallbackConversational"/> + </callback> + </service> + </component> </composite> diff --git a/sandbox/travelsample/contributions/shoppingcart-contribution/src/main/java/scatours/shoppingcart/CartStoreImpl.java b/sandbox/travelsample/contributions/shoppingcart-contribution/src/main/java/scatours/shoppingcart/CartStoreImpl.java index 64e9d83e86..934bc04f75 100644 --- a/sandbox/travelsample/contributions/shoppingcart-contribution/src/main/java/scatours/shoppingcart/CartStoreImpl.java +++ b/sandbox/travelsample/contributions/shoppingcart-contribution/src/main/java/scatours/shoppingcart/CartStoreImpl.java @@ -67,6 +67,5 @@ public class CartStoreImpl implements CartStore{ public void reset(){ trips.clear(); - } - + } } diff --git a/sandbox/travelsample/contributions/travelcatalog-contribution/src/main/java/scatours/travelcatalog/TravelCatalogImpl.java b/sandbox/travelsample/contributions/travelcatalog-contribution/src/main/java/scatours/travelcatalog/TravelCatalogImpl.java index 68eb3c38a2..124bdbf73c 100644 --- a/sandbox/travelsample/contributions/travelcatalog-contribution/src/main/java/scatours/travelcatalog/TravelCatalogImpl.java +++ b/sandbox/travelsample/contributions/travelcatalog-contribution/src/main/java/scatours/travelcatalog/TravelCatalogImpl.java @@ -120,5 +120,9 @@ public class TravelCatalogImpl implements TravelCatalogSearch, SearchCallback{ }
resultsReceivedCountdown.countDown();
- }
+ }
+
+ public void setPercentComplete(String searchComponent, int percentComplete){
+ // Not used at the moment
+ }
}
diff --git a/sandbox/travelsample/contributions/trip-contribution/src/main/java/scatours/trip/TripImpl.java b/sandbox/travelsample/contributions/trip-contribution/src/main/java/scatours/trip/TripImpl.java index 06aeeb2c63..224065876f 100644 --- a/sandbox/travelsample/contributions/trip-contribution/src/main/java/scatours/trip/TripImpl.java +++ b/sandbox/travelsample/contributions/trip-contribution/src/main/java/scatours/trip/TripImpl.java @@ -98,7 +98,7 @@ public class TripImpl implements Search, Book { System.out.println("Starting trip search");
try {
- this.wait(2000);
+ Thread.sleep(2000);
} catch(Exception ex){
// do nothing
}
@@ -107,6 +107,10 @@ public class TripImpl implements Search, Book { searchCallback.searchResults(searchSynch(tripLeg));
}
+ public int getPercentComplete(){
+ return 100;
+ }
+
public String book(TripItem tripItem) {
return "trip1";
}
diff --git a/sandbox/travelsample/launchers/fullapp-launcher/pom.xml b/sandbox/travelsample/launchers/fullapp-launcher/pom.xml index 236eebbb9a..97e2eddd05 100644 --- a/sandbox/travelsample/launchers/fullapp-launcher/pom.xml +++ b/sandbox/travelsample/launchers/fullapp-launcher/pom.xml @@ -35,6 +35,12 @@ <artifactId>tuscany-assembly</artifactId> <version>1.6-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> @@ -71,7 +77,7 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-implementation-java</artifactId> - <version>1.5-SNAPSHOT</version> + <version>1.6-SNAPSHOT</version> <scope>runtime</scope> </dependency> diff --git a/sandbox/travelsample/launchers/interaction-launcher/src/main/java/scatours/LaunchIntactionNode.java b/sandbox/travelsample/launchers/interaction-launcher/src/main/java/scatours/LaunchIntactionNode.java index 1c9b20ab5a..507bb3c0f0 100644 --- a/sandbox/travelsample/launchers/interaction-launcher/src/main/java/scatours/LaunchIntactionNode.java +++ b/sandbox/travelsample/launchers/interaction-launcher/src/main/java/scatours/LaunchIntactionNode.java @@ -39,11 +39,13 @@ public class LaunchIntactionNode { new SCAContribution("common", "../../contributions/common-contribution/target/classes"),
new SCAContribution("currency", "../../contributions/currency-contribution/target/classes"),
new SCAContribution("calendar", "../../contributions/calendar-contribution/target/classes"),
+ new SCAContribution("shoppingcart", "../../contributions/shoppingcart-contribution/target/classes"),
new SCAContribution("client", "../../contributions/interaction-client-contribution/target/classes"));
SCANode node2 = SCANodeFactory.newInstance().createSCANode("client.composite",
new SCAContribution("common", "../../contributions/common-contribution/target/classes"),
new SCAContribution("hotel", "../../contributions/hotel-contribution/target/classes"),
+ new SCAContribution("flight", "../../contributions/flight-contribution/target/classes"),
new SCAContribution("remoteService", "../../contributions/interaction-service-remote-contribution/target/classes"));
node2.start();
@@ -58,6 +60,15 @@ public class LaunchIntactionNode { Runnable requestResponseInteraction = ((SCAClient)node1).getService(Runnable.class, "InteractionRequestResponseClient/Runnable");
requestResponseInteraction.run();
+ Runnable onewayCallbackInteraction = ((SCAClient)node1).getService(Runnable.class, "InteractionOneWayCallbackClient/Runnable");
+ onewayCallbackInteraction.run();
+
+ Runnable conversationalInteraction = ((SCAClient)node1).getService(Runnable.class, "InteractionConversationClient/Runnable");
+ conversationalInteraction.run();
+
+ Runnable statefulCallbackInteraction = ((SCAClient)node1).getService(Runnable.class, "InteractionStatefulCallbackClient/Runnable");
+ statefulCallbackInteraction.run();
+
node1.stop();
node2.stop();
|