summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/contributions/travelcatalog/src/main
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/travelcatalog/src/main
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/travelcatalog/src/main')
-rw-r--r--sandbox/travelsample/contributions/travelcatalog/src/main/java/com/tuscanyscatours/travelcatalog/impl/TravelCatalogImpl.java92
1 files changed, 45 insertions, 47 deletions
diff --git a/sandbox/travelsample/contributions/travelcatalog/src/main/java/com/tuscanyscatours/travelcatalog/impl/TravelCatalogImpl.java b/sandbox/travelsample/contributions/travelcatalog/src/main/java/com/tuscanyscatours/travelcatalog/impl/TravelCatalogImpl.java
index 31e035bcdc..90351720bb 100644
--- a/sandbox/travelsample/contributions/travelcatalog/src/main/java/com/tuscanyscatours/travelcatalog/impl/TravelCatalogImpl.java
+++ b/sandbox/travelsample/contributions/travelcatalog/src/main/java/com/tuscanyscatours/travelcatalog/impl/TravelCatalogImpl.java
@@ -43,87 +43,85 @@ import com.tuscanyscatours.travelcatalog.TravelCatalogSearch;
* An implementation of the travel catalog service
*/
@Scope("COMPOSITE")
-@Service(interfaces={TravelCatalogSearch.class})
-public class TravelCatalogImpl implements TravelCatalogSearch, SearchCallback{
-
- @Reference
+@Service(interfaces = {TravelCatalogSearch.class})
+public class TravelCatalogImpl implements TravelCatalogSearch, SearchCallback {
+
+ @Reference
protected Search hotelSearch;
-
- @Reference
+
+ @Reference
protected Search flightSearch;
-
- @Reference
+
+ @Reference
protected Search carSearch;
-
- @Reference
- protected Search tripSearch;
-
+
+ @Reference
+ protected Search tripSearch;
+
@Property
public String quoteCurrencyCode = "USD";
-
+
@Reference
- protected CurrencyConverter currencyConverter;
-
+ protected CurrencyConverter currencyConverter;
+
@Context
protected ComponentContext componentContext;
-
+
private List<TripItem> searchResults = new ArrayList<TripItem>();
-
+
CountDownLatch resultsReceivedCountdown;
-
+
// TravelSearch methods
-
+
public TripItem[] search(TripLeg tripLeg) {
-
- resultsReceivedCountdown = new CountDownLatch(4);
+
+ resultsReceivedCountdown = new CountDownLatch(4);
searchResults.clear();
-
- ServiceReference<Search> dynamicHotelSearch =
- componentContext.getServiceReference(Search.class, "hotelSearch");
-
- dynamicHotelSearch.setCallbackID("HotelSearchCallbackID-" + tripLeg.getId());
+
+ ServiceReference<Search> dynamicHotelSearch = componentContext.getServiceReference(Search.class, "hotelSearch");
+
+ dynamicHotelSearch.setCallbackID("HotelSearchCallbackID-" + tripLeg.getId());
dynamicHotelSearch.getService().searchAsynch(tripLeg);
-
- flightSearch.searchAsynch(tripLeg);
+
+ flightSearch.searchAsynch(tripLeg);
carSearch.searchAsynch(tripLeg);
tripSearch.searchAsynch(tripLeg);
-
+
System.out.println("going into wait");
-
+
try {
- resultsReceivedCountdown.await();
- } catch (InterruptedException ex){
+ resultsReceivedCountdown.await();
+ } catch (InterruptedException ex) {
}
-
- for (TripItem tripItem : searchResults){
+
+ for (TripItem tripItem : searchResults) {
tripItem.setId(UUID.randomUUID().toString());
tripItem.setTripId(tripLeg.getId());
- tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(),
- quoteCurrencyCode,
- tripItem.getPrice()));
+ tripItem
+ .setPrice(currencyConverter.convert(tripItem.getCurrency(), quoteCurrencyCode, tripItem.getPrice()));
tripItem.setCurrency(quoteCurrencyCode);
}
-
+
return searchResults.toArray(new TripItem[searchResults.size()]);
}
-
+
// SearchCallback methods
-
- public synchronized void searchResults(TripItem[] items){
+
+ public synchronized void searchResults(TripItem[] items) {
RequestContext requestContext = componentContext.getRequestContext();
Object callbackID = requestContext.getServiceReference().getCallbackID();
System.out.println("Asynch response - " + callbackID);
-
+
if (items != null) {
- for(int i = 0; i < items.length; i++ ){
+ for (int i = 0; i < items.length; i++) {
searchResults.add(items[i]);
}
}
-
+
resultsReceivedCountdown.countDown();
- }
-
- public void setPercentComplete(String searchComponent, int percentComplete){
+ }
+
+ public void setPercentComplete(String searchComponent, int percentComplete) {
// Not used at the moment
}
}