Source:
public void planReservation(ReservationResource reservation) throws ResourceReservationException { if (reservation == null) throw new NullPointerException("Reservation, resources and period are required to plan a reservation."); IReservationAdministration reservationAdmin; try { reservationAdmin = serviceProvider.getCapability(reservation, IReservationAdministration.class); } catch (CapabilityNotFoundException c) { throw new ResourceReservationException(c); } Set<IRootResource> resources = reservationAdmin.getResources(); Period period = reservationAdmin.getPeriod(); if (resources.isEmpty()) throw new IllegalArgumentException("You need at least one resource in order to plan a reservation"); log.info("Planning reservation [ " + reservation.getId() + "]"); Date currentDate = getCurrentDate(); if (period.getStartdate().before(currentDate)) throw new IllegalArgumentException("The reservation period should be a future period."); checkResourcesAreAvailable(reservation); try { reservationAdmin = serviceProvider.getCapability(reservation, IReservationAdministration.class); reservationAdmin.setState(ReservationState.PLANNED); if (reservationAdmin.getPeriod().getStartdate().after(new Date(System.currentTimeMillis()))) { IService service = serviceProvider.getService(resource, "performReservation", ReservationResource.class); Trigger trigger = TriggerFactory.create(reservationAdmin.getPeriod().getStartdate()); ServiceExecution serviceExecution = new ServiceExecution(service, trigger); reservationsServicesExeceutions.put(reservation, serviceExecution); serviceExecutionScheduler.schedule(serviceExecution); } else { reservationPerformer.performReservation(reservation); } } catch (CapabilityNotFoundException c) { throw new ResourceReservationException(c); } catch (ServiceNotFoundException e) { log.error("Could not obtain performReservation service.", e); throw new ResourceReservationException(e); } catch (ServiceExecutionSchedulerException e) { throw new ResourceReservationException(e); } }

Target:
public void planReservation(ReservationResource reservation) throws ResourceReservationException { if (reservation == null) throw new NullPointerException("Reservation, resources and period are required to plan a reservation."); IReservationAdministration reservationAdmin; try { reservationAdmin = serviceProvider.getCapability(reservation, IReservationAdministration.class); } catch (CapabilityNotFoundException c) { throw new ResourceReservationException(c); } Set<IRootResource> resources = reservationAdmin.getResources(); Period period = reservationAdmin.getPeriod(); if (resources.isEmpty()) throw new IllegalArgumentException("You need at least one resource in order to plan a reservation"); log.info("Planning reservation [ " + reservation.getId() + "]"); Date currentDate = getCurrentDate(); if (period.getStartdate().before(currentDate)) throw new IllegalArgumentException("The reservation period should be a future period."); checkResourcesAreAvailable(reservation); try { reservationAdmin.setState(ReservationState.PLANNED); if (reservationAdmin.getPeriod().getStartdate().after(new Date(System.currentTimeMillis()))) { IService service = serviceProvider.getService(resource, "performReservation", ReservationResource.class); Trigger trigger = TriggerFactory.create(reservationAdmin.getPeriod().getStartdate()); ServiceExecution serviceExecution = new ServiceExecution(service, trigger); reservationsServicesExeceutions.put(reservation, serviceExecution); serviceExecutionScheduler.schedule(serviceExecution); } else { reservationPerformer.performReservation(reservation); } } catch (ServiceNotFoundException e) { log.error("Could not obtain performReservation service.", e); throw new ResourceReservationException(e); } catch (ServiceExecutionSchedulerException e) { throw new ResourceReservationException(e); } }