Java tutorial
/******************************************************************************* * Copyright (c) 2008, 2009 SOPERA GmbH. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * SOPERA GmbH - initial API and implementation *******************************************************************************/ package org.eclipse.swordfish.samples.cxf; import java.util.Arrays; import java.util.Timer; import java.util.TimerTask; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.swordfish.samples.cxf.domain.Flight; import org.eclipse.swordfish.samples.cxf.domain.Passenger; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; public class BookingServiceClientInvoker implements InitializingBean { private static final Log LOG = LogFactory.getLog(BookingServiceClientInvoker.class); private Integer delayBeforeSending = 5000; private BookingService bookingService; public BookingService getBookingService() { return bookingService; } public void setBookingService(BookingService bookingService) { this.bookingService = bookingService; } public Integer getDelayBeforeSending() { return delayBeforeSending; } public void setDelayBeforeSending(Integer delayBeforeSending) { this.delayBeforeSending = delayBeforeSending; } public void afterPropertiesSet() throws Exception { Assert.notNull(bookingService); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { try { performRequest(); } catch (Exception ex) { throw new RuntimeException(ex); } } }, delayBeforeSending); } private void performRequest() { LOG.info("Pefforming invocation on bookingService"); int id = bookingService.createReservation( Arrays.asList(new Passenger(5, "Homer", "Simpson", 43), new Passenger(6, "Marge", "Simpson", 42)), new Flight(10, "SP101")); LOG.info("The reservation was created with id = " + id); } }