From 5d233f4bfd30569617b6704ca41dd75c6c70d565 Mon Sep 17 00:00:00 2001 From: nash Date: Sat, 15 May 2010 15:29:33 +0000 Subject: Merge revision r944283 from trunk git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@944666 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscanyscatours/using/impl/CarPartnerImpl.java | 36 ----------- .../tuscanyscatours/using/impl/CarVendorImpl.java | 34 ---------- .../using/impl/CurrencyConverterImpl.java | 45 ------------- .../tuscanyscatours/using/impl/CustomerImpl.java | 47 -------------- .../using/impl/FlightPartnerImpl.java | 31 --------- .../using/impl/HotelPartnerImpl.java | 31 --------- .../using/impl/TripBookingImpl.java | 73 ---------------------- .../usingsca/impl/CarPartnerImpl.java | 36 +++++++++++ .../usingsca/impl/CarVendorImpl.java | 34 ++++++++++ .../usingsca/impl/CurrencyConverterImpl.java | 45 +++++++++++++ .../usingsca/impl/CustomerImpl.java | 47 ++++++++++++++ .../usingsca/impl/FlightPartnerImpl.java | 31 +++++++++ .../usingsca/impl/HotelPartnerImpl.java | 31 +++++++++ .../usingsca/impl/TripBookingImpl.java | 73 ++++++++++++++++++++++ 14 files changed, 297 insertions(+), 297 deletions(-) delete mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CarPartnerImpl.java delete mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CarVendorImpl.java delete mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CurrencyConverterImpl.java delete mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CustomerImpl.java delete mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/FlightPartnerImpl.java delete mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/HotelPartnerImpl.java delete mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/TripBookingImpl.java create mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CarPartnerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CarVendorImpl.java create mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CurrencyConverterImpl.java create mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CustomerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/FlightPartnerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/HotelPartnerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/TripBookingImpl.java (limited to 'sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java') diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CarPartnerImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CarPartnerImpl.java deleted file mode 100644 index 687fc49230..0000000000 --- a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CarPartnerImpl.java +++ /dev/null @@ -1,36 +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 com.tuscanyscatours.using.impl; - -import java.util.Date; -import org.osoa.sca.annotations.Reference; -import com.tuscanyscatours.Cars; - -public class CarPartnerImpl implements Cars { - - @Reference - protected Cars[] cars; - - @Reference(required=false) - protected Cars[] luxuryCars; - - public String bookCar(Date pickup, int days, String carClass) { - return cars[0].bookCar(pickup, days, carClass); - } -} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CarVendorImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CarVendorImpl.java deleted file mode 100644 index f8644bab2c..0000000000 --- a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CarVendorImpl.java +++ /dev/null @@ -1,34 +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 com.tuscanyscatours.using.impl; - -import java.util.Date; -import com.tuscanyscatours.Cars; - -public class CarVendorImpl implements Cars { - - protected int minAge; // implicitly defines an SCA property - - public String bookCar(Date pickup, int days, String carClass) { - System.out.println("Booking confirmed for pickup date " + pickup + - " duration " + days + " days in a " + carClass + - " class car"); - return "CV234"; - } -} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CurrencyConverterImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CurrencyConverterImpl.java deleted file mode 100644 index 3749221aa9..0000000000 --- a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CurrencyConverterImpl.java +++ /dev/null @@ -1,45 +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 com.tuscanyscatours.using.impl; - -import java.math.BigDecimal; -import org.osoa.sca.annotations.Property; -import com.tuscanyscatours.CurrencyConverter; - -public class CurrencyConverterImpl implements CurrencyConverter { - - @Property - protected String fromCurrency; - - @Property - protected String toCurrency; - - public BigDecimal convert(BigDecimal amount) { - return amount.multiply(getRate(toCurrency)) - .divide(getRate(fromCurrency), 2, 0); - } - - private BigDecimal getRate(String currency) { - int rate = 0; - for (int i = 0; i < currency.length(); i++) { - rate += currency.codePointAt(i); - } - return new BigDecimal(rate).divide(new BigDecimal(100)); - } -} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CustomerImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CustomerImpl.java deleted file mode 100644 index 84ca6c7593..0000000000 --- a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/CustomerImpl.java +++ /dev/null @@ -1,47 +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 com.tuscanyscatours.using.impl; - -import org.osoa.sca.annotations.Property; -import com.tuscanyscatours.Address; -import com.tuscanyscatours.BillingAddress; -import com.tuscanyscatours.CustomerInfo; - -public class CustomerImpl implements CustomerInfo { - - @Property - protected BillingAddress billingAddress; - - @Property - protected Address deliveryAddress; - - public String getBillingAddress() { - return billingAddress.getStreet() + ", " + - billingAddress.getCity() + ", " + - billingAddress.getState() + " " + - billingAddress.getZip(); - } - - public String getDeliveryAddress() { - return deliveryAddress.getStreet() + ", " + - deliveryAddress.getCity() + ", " + - deliveryAddress.getState() + " " + - deliveryAddress.getZip(); - } -} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/FlightPartnerImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/FlightPartnerImpl.java deleted file mode 100644 index c5d6747a6b..0000000000 --- a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/FlightPartnerImpl.java +++ /dev/null @@ -1,31 +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 com.tuscanyscatours.using.impl; - -import java.util.Date; -import com.tuscanyscatours.Flights; - -public class FlightPartnerImpl implements Flights { - - public String bookFlight(String flightNumber, Date date, int seats, String flightClass) { - System.out.println("Booking confirmed for flight " + flightNumber + " on date " + - date + " with " + seats + " seats in " + flightClass + " class"); - return "FP345"; - } -} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/HotelPartnerImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/HotelPartnerImpl.java deleted file mode 100644 index 6cca73b0d0..0000000000 --- a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/HotelPartnerImpl.java +++ /dev/null @@ -1,31 +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 com.tuscanyscatours.using.impl; - -import java.util.Date; -import com.tuscanyscatours.Hotels; - -public class HotelPartnerImpl implements Hotels { - - public String bookHotel(String hotelCode, Date date, int days, String roomType) { - System.out.println("Booking confirmed for hotel " + hotelCode + " arriving on " + - date + " for " + days + " days in a " + roomType + " room"); - return "HP456"; - } -} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/TripBookingImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/TripBookingImpl.java deleted file mode 100644 index 9d81a0d4ed..0000000000 --- a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/using/impl/TripBookingImpl.java +++ /dev/null @@ -1,73 +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 com.tuscanyscatours.using.impl; - -import java.text.DateFormat; -import java.util.Date; -import org.osoa.sca.annotations.Reference; - -import com.tuscanyscatours.Bookings; -import com.tuscanyscatours.Cars; -import com.tuscanyscatours.Flights; -import com.tuscanyscatours.Hotels; - -public class TripBookingImpl implements Bookings { - - public TripBookingImpl(@Reference(name="cars") Cars cars) { - this.cars = cars; - } - - protected Cars cars; - - @Reference - protected Flights flights; - - private Hotels hotels; - - @Reference - public void setHotels(Hotels hotels) { - this.hotels = hotels; - } - - public String newBooking(String trip, int people) { - /* In a real implementation this method would look up the trip code - in the travel catalog to get details of the car, flight and hotel - bookings needed. Instead these details are hard-wired here for - test purposes. */ - Date startDate = new Date(); //TEMP - need to fix - /* - try { - startDate = DateFormat.getInstance().parse("7 Jul, 2012"); - } catch (Exception e) { - e.printStackTrace(); - } - */ - - if (people > 0) { - cars.bookCar(startDate, 7, "B"); - flights.bookFlight("AA123", startDate, people, "Y"); - hotels.bookHotel("DBH", startDate, 7, "SUP"); - - return "HW3546"; - - } else { - return "NONE"; - } - } -} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CarPartnerImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CarPartnerImpl.java new file mode 100644 index 0000000000..cb354e0ccc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CarPartnerImpl.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.tuscanyscatours.usingsca.impl; + +import java.util.Date; +import org.osoa.sca.annotations.Reference; +import com.tuscanyscatours.Cars; + +public class CarPartnerImpl implements Cars { + + @Reference + protected Cars[] cars; + + @Reference(required=false) + protected Cars[] luxuryCars; + + public String bookCar(Date pickup, int days, String carClass) { + return cars[0].bookCar(pickup, days, carClass); + } +} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CarVendorImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CarVendorImpl.java new file mode 100644 index 0000000000..13c8de7f30 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CarVendorImpl.java @@ -0,0 +1,34 @@ +/* + * 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 com.tuscanyscatours.usingsca.impl; + +import java.util.Date; +import com.tuscanyscatours.Cars; + +public class CarVendorImpl implements Cars { + + protected int minAge; // implicitly defines an SCA property + + public String bookCar(Date pickup, int days, String carClass) { + System.out.println("Booking confirmed for pickup date " + pickup + + " duration " + days + " days in a " + carClass + + " class car"); + return "CV234"; + } +} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CurrencyConverterImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CurrencyConverterImpl.java new file mode 100644 index 0000000000..a7687c61f7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CurrencyConverterImpl.java @@ -0,0 +1,45 @@ +/* + * 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 com.tuscanyscatours.usingsca.impl; + +import java.math.BigDecimal; +import org.osoa.sca.annotations.Property; +import com.tuscanyscatours.CurrencyConverter; + +public class CurrencyConverterImpl implements CurrencyConverter { + + @Property + protected String fromCurrency; + + @Property + protected String toCurrency; + + public BigDecimal convert(BigDecimal amount) { + return amount.multiply(getRate(toCurrency)) + .divide(getRate(fromCurrency), 2, 0); + } + + private BigDecimal getRate(String currency) { + int rate = 0; + for (int i = 0; i < currency.length(); i++) { + rate += currency.codePointAt(i); + } + return new BigDecimal(rate).divide(new BigDecimal(100)); + } +} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CustomerImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CustomerImpl.java new file mode 100644 index 0000000000..361d5b35c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/CustomerImpl.java @@ -0,0 +1,47 @@ +/* + * 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 com.tuscanyscatours.usingsca.impl; + +import org.osoa.sca.annotations.Property; +import com.tuscanyscatours.Address; +import com.tuscanyscatours.BillingAddress; +import com.tuscanyscatours.CustomerInfo; + +public class CustomerImpl implements CustomerInfo { + + @Property + protected BillingAddress billingAddress; + + @Property + protected Address deliveryAddress; + + public String getBillingAddress() { + return billingAddress.getStreet() + ", " + + billingAddress.getCity() + ", " + + billingAddress.getState() + " " + + billingAddress.getZip(); + } + + public String getDeliveryAddress() { + return deliveryAddress.getStreet() + ", " + + deliveryAddress.getCity() + ", " + + deliveryAddress.getState() + " " + + deliveryAddress.getZip(); + } +} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/FlightPartnerImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/FlightPartnerImpl.java new file mode 100644 index 0000000000..e076a725d1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/FlightPartnerImpl.java @@ -0,0 +1,31 @@ +/* + * 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 com.tuscanyscatours.usingsca.impl; + +import java.util.Date; +import com.tuscanyscatours.Flights; + +public class FlightPartnerImpl implements Flights { + + public String bookFlight(String flightNumber, Date date, int seats, String flightClass) { + System.out.println("Booking confirmed for flight " + flightNumber + " on date " + + date + " with " + seats + " seats in " + flightClass + " class"); + return "FP345"; + } +} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/HotelPartnerImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/HotelPartnerImpl.java new file mode 100644 index 0000000000..86c98517e7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/HotelPartnerImpl.java @@ -0,0 +1,31 @@ +/* + * 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 com.tuscanyscatours.usingsca.impl; + +import java.util.Date; +import com.tuscanyscatours.Hotels; + +public class HotelPartnerImpl implements Hotels { + + public String bookHotel(String hotelCode, Date date, int days, String roomType) { + System.out.println("Booking confirmed for hotel " + hotelCode + " arriving on " + + date + " for " + days + " days in a " + roomType + " room"); + return "HP456"; + } +} diff --git a/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/TripBookingImpl.java b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/TripBookingImpl.java new file mode 100644 index 0000000000..04c06a8fe6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-travelsample-1.0/contributions/usingsca/src/main/java/com/tuscanyscatours/usingsca/impl/TripBookingImpl.java @@ -0,0 +1,73 @@ +/* + * 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 com.tuscanyscatours.usingsca.impl; + +import java.text.DateFormat; +import java.util.Date; +import org.osoa.sca.annotations.Reference; + +import com.tuscanyscatours.Bookings; +import com.tuscanyscatours.Cars; +import com.tuscanyscatours.Flights; +import com.tuscanyscatours.Hotels; + +public class TripBookingImpl implements Bookings { + + public TripBookingImpl(@Reference(name="cars") Cars cars) { + this.cars = cars; + } + + protected Cars cars; + + @Reference + protected Flights flights; + + private Hotels hotels; + + @Reference + public void setHotels(Hotels hotels) { + this.hotels = hotels; + } + + public String newBooking(String trip, int people) { + /* In a real implementation this method would look up the trip code + in the travel catalog to get details of the car, flight and hotel + bookings needed. Instead these details are hard-wired here for + test purposes. */ + Date startDate = new Date(); //TEMP - need to fix + /* + try { + startDate = DateFormat.getInstance().parse("7 Jul, 2012"); + } catch (Exception e) { + e.printStackTrace(); + } + */ + + if (people > 0) { + cars.bookCar(startDate, 7, "B"); + flights.bookFlight("AA123", startDate, people, "Y"); + hotels.bookHotel("DBH", startDate, 7, "SUP"); + + return "HW3546"; + + } else { + return "NONE"; + } + } +} -- cgit v1.2.3