Java Reference
In-Depth Information
This is the client facing interface. There is no coupling between the client facing interface exposed
via the gateway component and the interface of the service that ultimately handles the messages. I use
the interface for the service and the client to simplify the names needed to understand everything that's
going on. This is not like traditional, synchronous remoting in which the service interface and the client
interface match.
In this example, you're using two very simple objects for demonstration: HotelReservationSearch
and HotelReservation . There is nothing interesting about these objects in the slightest; they are simple
POJOs that implement Serializable and contain a few accessor/mutators to flesh out the example
domain.
The client Java code demonstrates how all of this comes together:
package com.apress.springenterpriserecipes.springintegration.myholiday;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) throws Throwable {
ClassPathXmlApplicationContext classPathXmlApplicationContext = new
ClassPathXmlApplicationContext("solution041_service.xml");
classPathXmlApplicationContext.start();
// setup the input parameter
Date now = new Date();
HotelReservationSearch hotelReservationSearch = new HotelReservationSearch(
200f, 2,
DateUtils.add(now, Calendar.DATE, 1),
DateUtils.add(now, Calendar.DATE, 8));
ClassPathXmlApplicationContext classPathXmlApplicationContext1 =
new ClassPathXmlApplicationContext("solution041_client.xml");
classPathXmlApplicationContext1.start();
// get a hold of our gateway proxy (you might
// imagine injecting this into another service just like
// you would a Hibernate DAO, for example)
VacationService vacationService = (VacationService)
classPathXmlApplicationContext1.getBean("vacationService");
List<HotelReservation> results = vacationService.findHotels(
hotelReservationSearch);
System.out.printf("Found %s results.", results.size());
System.out.println();
for (HotelReservation reservation : results) {
System.out.printf("\t%s", reservation.toString());
System.out.println();
}
}
}
Search WWH ::




Custom Search