Use the example on p.211 from
EJB in Action :
The method annotated with @Timeout to mark it as the method responsible for executing the task with the timer completes.
@Stateless
public class FlyerBean{
@Resource
private TimerService timerService;
...
public void scheduleFlyer(ScheduleExpression se, Email email){
TimeConfig tc = new TimerConfig(email, true);
Timer timer = timerService.createCalendarTime(se,tc);
...
}
@Timeout
public void send(Timer timer){
if (time.getInfo() instanceof Email){
Email email = (Email)timer.getInfo();
//Retrieve bidder/ seller and email.
}
}
}
ScheduleExpression se = new ScheduleExpression();
se.month(2).dayOfMonth(14).year(2012).hour(11).minute(30);
The code says the send method will be invoked on 2/14/2012 at 11:30.
What about a schedule expression ?
This schedule never times out. The times keeps increasing from 0:0:0, 0:20:30, 0:20:40 and so on.
The @Timeout method won't be invoked ? (I haven't tried it yet.)
@Timeout means the time when the time matches the schedule expression.
With an increasing time, will @Timeout method be invoked ?