-
1. Re: Persitant Bean for the life of the application
kyatim Jun 21, 2010 5:21 AM (in response to dave2010)You can use Quartz to do it.
You have to develop a Seam component that start after Seam Init ( fired by the PostInitialization Event) that will start scheduled actions).See Seam doc for Seam / Quartz integration!
-
2. Re: Persitant Bean for the life of the application
lvdberg Jun 21, 2010 5:23 AM (in response to dave2010)Hi,
The Seam docs and examples contain very nice examples of the use of the Quartz timer service. This works like a charm.
Create a bean which has the service you want to trigger every n-times.
Give it a name with the Name Annotation : doSomethingHandler
This service needs to have a method with the following signature:
public QuartzTriggerHandle doWhatYouNeedToDo(@Expiration Date when, @IntervalDuration Long interval, @FinalExpiration Date endDate) { /// Do what you need to do }
That all there is!
Leo
The you need a piece of code which triggers this method: A simple example: private QuartzTriggerHandle doSomething; ... doSomething = doSomethingHandlerdoWhatYouNeedToDo(when, interval, until); // Meaning when is the start date // Interval is once a day // untul is the end date
You need the handle in another bean to start and stop the timer. If you look into the example you will see that the method has a return value of null, That doesn't mean it really returns a null. The interception is handled by Seam, which gets the real handle.
Don't forget to configure the Quarts timer in components.xml !!
<async:quartz-dispatcher />
-
3. Re: Persitant Bean for the life of the application
dave2010 Jun 22, 2010 12:12 AM (in response to dave2010)Thanks, this has been very helpful
Dave