package timer; import javax.ejb.Schedule; import javax.ejb.Singleton; import javax.ejb.Timer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @Singleton public class TimerTestBean implements TimerTest { private static final Log LOGGER = LogFactory.getLog(TimerTestBean.class); private int counter = 0; public TimerTestBean() { } @Schedule(second = "*", minute = "*/1", hour = "*", persistent = false) public void execute(final Timer timer) { LOGGER.info("Executing TimerTestBean"); if (counter == 0) { counter++; LOGGER.info("Throwing exception: [" + Thread.currentThread().getName() + "]"); throw new RuntimeException("Screw you"); } else { LOGGER.info("Sleeping 2 minutes: [" + Thread.currentThread().getName() + "]"); try { Thread.sleep(90000); } catch (InterruptedException e) { } } LOGGER.info("Finished executing TimerTestBean"); } }