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

oskar.carlstedt do-not-reply at jboss.com
Tue Apr 1 09:36:46 EDT 2008


Here is a short eaxample:


  | @Service
  | @Management(MyServiceManagement.class)
  | @Depends("jboss.ws:service=DeployerInterceptorEJB3")
  | public class MyService implements MyServiceManagement {
  | 	
  |    private Timer timer = null;
  | 
  |    @Resource
  |    private EJBContext ejbContext;
  | 
  |    public void start() throws Exception {
  |       timer = ejbContext.getTimerService().createTimer(1000, "Say Hello!!");
  |    }
  | 
  |    @Timeout
  |    public void timeout(Timer timer) {
  |       System.out.println(timer.getInfo());
  |       timer = ejbContext.getTimerService().createTimer(1000, "Say Hello again!!");
  |    }
  | 
  |    public void stop() {
  |       timer.cancel();
  |    }
  | }
  | 
  | 
  | public interface MyServiceManagement {
  | 
  | 	public void start() throws Exception;
  | 
  | 	public void stop() throws Exception;
  | }
  | 
  | 
  | 


/Oskar

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

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



More information about the jboss-user mailing list