dev@glassfish.java.net

Timer Service

From: Dyego Souza Dantas Leal <dyego.leal_at_gmail.com>
Date: Tue, 27 Mar 2007 10:52:21 -0300

I'm creating a EJB3 timer service...
but... i'm create a timer with scheduleTimer(1000) and the timer not
response... not call timeout method... what is worng ?

The code is:

@Stateless
public class TimerToCreateBean implements
br.com.escriba.ejb3.TimerToCreateLocal {
   
    /** Creates a new instance of TimerToCreateBean */
    public TimerToCreateBean() {
    }
   
    @Resource
    TimerService timerService;
    private @Resource SessionContext ctx;
   
   
    public void createTimer(long intervalDuration) {
        Timer timer = timerService.createTimer(intervalDuration,
intervalDuration,
                "Created new timer");
    }
   
    public void scheduleTimer(long milliseconds)
   {
      ctx.getTimerService().createTimer(new Date(new Date().getTime() +
milliseconds), "Hello World");
   }

   
    @Timeout
    public void timeout(Timer timer) {
        System.out.println("TimerBean: timeout occurred");
    }
}




-- 
-------------------------------------------------------------------------
++  Dyego Souza Dantas Leal   ++           Dep. Desenvolvimento   -------------------------------------------------------------------------
               E S C R I B A   I N F O R M A T I C A
        ***        http://www.go-java.com/blog        ***
-------------------------------------------------------------------------
The only stupid question is the unasked one (somewhere in Linux's HowTo)
Linux registred user : #230601
--                                        ICQ   : 1647350
$ look into "my eyes"                     Phone : +55 041 2106-1212    
look: cannot open my eyes                 Fax   : +55 041 3296-6640     -------------------------------------------------------------------------
	             Reply: dyego_at_escriba.com.br