-
1. Re: How to start the class when start up the jboss?
osterday Aug 17, 2006 10:33 AM (in response to poonwingyee)I think the best way would be to use an MBean to do this. Check out the JBoss docs for MBeans - they are really a great way to do this type of stuff, if I understand your problem correctly.
Another option is to create a servlet and set it to load on startup - check the docs for web.xml to see this. Hope that helps! Also, MBeans are allowed to create threads and EJBs aren't supposed to create threads according to the spec.
If you want some cool scheduling type of stuff, check into Quartz - it's great.
There is also some timer stuff in EJB3, but I haven't done anything with that yet. -
2. Re: How to start the class when start up the jboss?
danialdy Aug 17, 2006 10:40 PM (in response to poonwingyee)I have the best practice:
From EJB 2.1, there's a timer service. You can create a Timer (can repeat automatically with specified interval time) with it.
So, you should create an EJB that implements TimedObject, in the method ejbTimeOut, send the email as you want. And you could create a method to start a timer.
When the JBoss Application Server starts at the first time, the EJB can not be called automatically, create a servlet and set it to load on startup(Just like what osterday said), in the servlet call the EJB's method.
The auto-startup servlet should be setted to depends on the EJB, then JBoss will load the EJB first.
Hope helpful!
Email: duy@routon.com