org.springframework.webflow.samples.booking
Class JpaTravelService

java.lang.Object
  extended by org.springframework.webflow.samples.booking.JpaTravelService
All Implemented Interfaces:
TravelService

@Service(value="travelService")
@Repository
public class JpaTravelService
extends Object
implements TravelService

A JPA-based implementation of the Booking Service. Delegates to a JPA entity manager to issue data access calls against the backing repository. The EntityManager reference is provided by the managing container (Spring) automatically.


Constructor Summary
JpaTravelService()
           
 
Method Summary
 Hotel addHotel(Hotel hotel)
           
 Preference addPreference(String userName, Preference preference)
          Create a new user preference
 void cancelBooking(Long id)
          Cancel an existing booking.
 Booking createBooking(Long hotelId, String username)
          Create a new, transient hotel booking instance for the given user.
 void deletePreference(Long id)
           
 List<Booking> findBookings(String username)
          Find bookings made by the given user
 Hotel findHotelById(Long id)
          Find hotels by their identifier.
 List<Hotel> findHotels(SearchCriteria criteria)
          Find hotels available for booking by some criteria.
 Preference findPreferenceById(Long id)
           
 List<Preference> findPreferences(String username)
           
 void savePreference(Preference preference)
           
 void setEntityManager(javax.persistence.EntityManager em)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JpaTravelService

public JpaTravelService()
Method Detail

setEntityManager

public void setEntityManager(javax.persistence.EntityManager em)

findBookings

@Transactional(readOnly=true)
public List<Booking> findBookings(String username)
Description copied from interface: TravelService
Find bookings made by the given user

Specified by:
findBookings in interface TravelService
Parameters:
username - the user's name
Returns:
their bookings

findHotels

@Transactional(readOnly=true)
public List<Hotel> findHotels(SearchCriteria criteria)
Description copied from interface: TravelService
Find hotels available for booking by some criteria.

Specified by:
findHotels in interface TravelService
Parameters:
criteria - the search criteria
Returns:
a list of hotels meeting the criteria

findHotelById

@Transactional(readOnly=true)
public Hotel findHotelById(Long id)
Description copied from interface: TravelService
Find hotels by their identifier.

Specified by:
findHotelById in interface TravelService
Parameters:
id - the hotel id
Returns:
the hotel

createBooking

@Transactional(readOnly=true)
public Booking createBooking(Long hotelId,
                                           String username)
Description copied from interface: TravelService
Create a new, transient hotel booking instance for the given user.

Specified by:
createBooking in interface TravelService
Parameters:
hotelId - the hotelId
username - the user name
Returns:
the new transient booking instance

cancelBooking

@Transactional
public void cancelBooking(Long id)
Description copied from interface: TravelService
Cancel an existing booking.

Specified by:
cancelBooking in interface TravelService
Parameters:
id - the booking id

addPreference

@Transactional
public Preference addPreference(String userName,
                                              Preference preference)
Description copied from interface: TravelService
Create a new user preference

Specified by:
addPreference in interface TravelService
preference - TODO
Returns:
the new preference instance

deletePreference

@Transactional
public void deletePreference(Long id)
Specified by:
deletePreference in interface TravelService

findPreferences

@Transactional(readOnly=true)
public List<Preference> findPreferences(String username)
Specified by:
findPreferences in interface TravelService
Returns:

findPreferenceById

@Transactional
public Preference findPreferenceById(Long id)
Specified by:
findPreferenceById in interface TravelService
Returns:

savePreference

@Transactional
public void savePreference(Preference preference)
Specified by:
savePreference in interface TravelService

addHotel

@Transactional
public Hotel addHotel(Hotel hotel)
Specified by:
addHotel in interface TravelService


Copyright © 2009 SpringSource, Inc. All Rights Reserved.