[jboss-user] [EJB 3.0] - How to start a session bean as soon as it is deployed

masoodah@mdsit.com do-not-reply at jboss.com
Fri Feb 1 14:10:27 EST 2008


Hi,

I want a session bean or other to start as soon as I deploy the application. Basically my need is to access a certain table in the database periodically using @Timeout Timer Serivce.
My bean looks like so
@Stateless
public class AdSetScheduleBean implements AdSetScheduleRemote, AdSetScheduleLocal {
    
    // Add business logic below. (Right-click in editor and choose
    // "EJB Methods > Add Business Method" or "Web Service > Add Operation")
    

    public AdSetScheduleBean() {
             }
    
     @PostConstruct
    public void init() {
        System.out.println("I am in Postconstructor of AdSetScheduleBean");
        
    }
 
     @Resource TimerService timerService;
     
     //Method to be called on timer expiration
     @Timeout
     public void CheckAdSetSchedule( Timer timer ){
         // Define method here
         
     }
     
     public void startTimer(){
         System.out.println("I am in startTimer");
         long timeNow = System.currentTimeMillis();
         long interval = 5;
         
         timerService.createTimer(timeNow, interval, null);
     }
}

How do I wake this bean on startup and have it check Status ar regular intervals.
Thanks

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125643#4125643

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4125643



More information about the jboss-user mailing list