summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-05 21:14:49 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-11-05 21:14:49 +0000
commit8c049462ff6387d8c3f69f4e42a4c4b36e38a90c (patch)
tree3e6b1ec1ab2e2a724d9228ca55052394c3034060 /sandbox/travelsample/contributions/interaction-client/src/main/java/scatours
parent68c3920fc0ba41c6a9ebf062bd41e5ebf647e51b (diff)
Format the code
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@833174 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/contributions/interaction-client/src/main/java/scatours')
-rw-r--r--sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionConversationClientImpl.java45
-rw-r--r--sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionLocalClientImpl.java35
-rw-r--r--sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionOneWayCallbackClientImpl.java62
-rw-r--r--sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionRemoteClientImpl.java52
-rw-r--r--sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionRequestResponseClientImpl.java15
-rw-r--r--sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionStatefulCallbackClientImpl.java72
6 files changed, 137 insertions, 144 deletions
diff --git a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionConversationClientImpl.java b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionConversationClientImpl.java
index 0bb662e737..290e6e6aee 100644
--- a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionConversationClientImpl.java
+++ b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionConversationClientImpl.java
@@ -19,60 +19,55 @@
package scatours.client.impl;
-import java.util.concurrent.CountDownLatch;
-
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;
-import com.tuscanyscatours.common.Search;
-import com.tuscanyscatours.common.SearchCallback;
import com.tuscanyscatours.common.TripItem;
-import com.tuscanyscatours.common.TripLeg;
import com.tuscanyscatours.shoppingcart.CartStore;
@Scope("COMPOSITE")
@Service(Runnable.class)
public class InteractionConversationClientImpl implements Runnable {
-
+
@Reference
protected CartStore cartStoreConversation;
-
+
public void run() {
- System.out.println("\nCalling cart store using the conversational interaction pattern");
+ 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);
- // 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){
+ 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){
+ for (TripItem item : tripItems) {
System.out.println("Item - " + item.getDescription());
}
- }
-
- private TripItem getTestTripItem(){
+ }
+
+ 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;
- }
+ return tripItem;
+ }
}
diff --git a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionLocalClientImpl.java b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionLocalClientImpl.java
index b5594dfa7e..ca3cb2874a 100644
--- a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionLocalClientImpl.java
+++ b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionLocalClientImpl.java
@@ -27,26 +27,27 @@ import com.tuscanyscatours.common.TripLeg;
@Service(Runnable.class)
public class InteractionLocalClientImpl implements Runnable {
-
+
@Reference
protected Calendar calendarLocal;
- public void run() {
- System.out.println("\nCalling calendar component over a local binding");
- TripLeg tripLeg = getTestTripLeg();
- String toDate = calendarLocal.getEndDate(tripLeg.getFromDate(), 10);
- tripLeg.setToDate(toDate);
- System.out.println("Calculated trip end date - " + toDate);;
+ public void run() {
+ System.out.println("\nCalling calendar component over a local binding");
+ TripLeg tripLeg = getTestTripLeg();
+ String toDate = calendarLocal.getEndDate(tripLeg.getFromDate(), 10);
+ tripLeg.setToDate(toDate);
+ System.out.println("Calculated trip end date - " + toDate);
+ ;
}
-
- 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;
+
+ 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/src/main/java/scatours/client/impl/InteractionOneWayCallbackClientImpl.java b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionOneWayCallbackClientImpl.java
index d764917276..9689ce8e0c 100644
--- a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionOneWayCallbackClientImpl.java
+++ b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionOneWayCallbackClientImpl.java
@@ -32,47 +32,47 @@ import com.tuscanyscatours.common.TripLeg;
@Scope("COMPOSITE")
@Service(Runnable.class)
-public class InteractionOneWayCallbackClientImpl implements Runnable, SearchCallback{
-
+public class InteractionOneWayCallbackClientImpl 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
+ 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){
+ } catch (InterruptedException ex) {
}
}
-
- public void searchResults(TripItem[] items){
- for (TripItem tripItem : items){
+
+ 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){
+ }
+
+ 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;
- }
+ }
+
+ 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/src/main/java/scatours/client/impl/InteractionRemoteClientImpl.java b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionRemoteClientImpl.java
index 91350fdc88..1fd9d9cbe8 100644
--- a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionRemoteClientImpl.java
+++ b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionRemoteClientImpl.java
@@ -29,36 +29,36 @@ import com.tuscanyscatours.common.TripLeg;
@Service(Runnable.class)
public class InteractionRemoteClientImpl implements Runnable, SearchCallback {
-
+
@Reference
protected Search hotelSearchRemote;
-
+
public void run() {
- System.out.println("\nCalling hotel component over a remote binding");
- TripLeg tripLeg = getTestTripLeg();
- TripItem[] tripItems = hotelSearchRemote.searchSynch(tripLeg);
- for (TripItem tripItem : tripItems){
- System.out.println("Found hotel - " + tripItem.getName());
- }
+ System.out.println("\nCalling hotel component over a remote binding");
+ TripLeg tripLeg = getTestTripLeg();
+ TripItem[] tripItems = hotelSearchRemote.searchSynch(tripLeg);
+ for (TripItem tripItem : tripItems) {
+ System.out.println("Found hotel - " + tripItem.getName());
+ }
}
-
- public void searchResults(TripItem[] items){
+
+ public void searchResults(TripItem[] items) {
// we are calling the hotel component synchronously here
- // so the callback interface is not used
- }
-
- public void setPercentComplete(String searchComponent, int percentComplete){
+ // 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");
- 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;
- }
+ }
+
+ 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/src/main/java/scatours/client/impl/InteractionRequestResponseClientImpl.java b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionRequestResponseClientImpl.java
index 47f9be540b..d1438434ae 100644
--- a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionRequestResponseClientImpl.java
+++ b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionRequestResponseClientImpl.java
@@ -22,21 +22,18 @@ package scatours.client.impl;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
-import com.tuscanyscatours.calendar.Calendar;
-
-import com.tuscanyscatours.common.TripLeg;
import com.tuscanyscatours.currencyconverter.CurrencyConverter;
@Service(Runnable.class)
public class InteractionRequestResponseClientImpl implements Runnable {
-
+
@Reference
protected CurrencyConverter currencyConverterRequestResponse;
- public void run() {
- System.out.println("\nCalling currency converter component using request response interation pattern");
- double exchangeRate = currencyConverterRequestResponse.getExchangeRate("GBP", "USD");
- System.out.println("GBP to USD exchange rate is " + exchangeRate);
+ public void run() {
+ System.out.println("\nCalling currency converter component using request response interation pattern");
+ double exchangeRate = currencyConverterRequestResponse.getExchangeRate("GBP", "USD");
+ System.out.println("GBP to USD exchange rate is " + exchangeRate);
}
-
+
}
diff --git a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionStatefulCallbackClientImpl.java b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionStatefulCallbackClientImpl.java
index 5d8285835e..87cea904ac 100644
--- a/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionStatefulCallbackClientImpl.java
+++ b/sandbox/travelsample/contributions/interaction-client/src/main/java/scatours/client/impl/InteractionStatefulCallbackClientImpl.java
@@ -24,7 +24,6 @@ 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;
@@ -37,62 +36,63 @@ import com.tuscanyscatours.common.TripLeg;
@Scope("CONVERSATION")
@Service(Runnable.class)
public class InteractionStatefulCallbackClientImpl 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 =
+ 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");
+ 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){
+ } catch (Exception ex) {
// do nothing
}
System.out.println("Flight search is " + flightSearch.getPercentComplete() + "% complete");
-
- // wait for responses to come back
+
+ // wait for responses to come back
try {
resultsReceivedCountdown.await();
- } catch (InterruptedException ex){
+ } catch (InterruptedException ex) {
}
}
-
- public void searchResults(TripItem[] items){
- System.out.println("Received results in conversation - " + componentContext.getRequestContext().getServiceReference().getConversation().getConversationID());
- for (TripItem tripItem : items){
+
+ 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){
+ }
+
+ 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;
- }
+ }
+
+ 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;
+ }
}