Hi Andreas,
I saw Vadim already gave you some infos.
I am using directly the Quartz Scheduler Agent from Cocoon aand don't know much more about Lenya.
Nevertheless, the mechanism should be the same.
Andreas Hartmann wrote:
Hi Cocoon devs,
in the process of moving the Lenya scheduler to Cocoon components, I played a little bit with the cron block.
At first I tried to invoke a Lenya service from the scheduler by obtaining the service directly via the ServiceableJob's service manager. But this way I ended up with exceptions, because the request URI was empty. Originally, the service was only invoked from the web interface via flowscript.
Some questions:
1) Is it possible to initialize a cron job with the original environment information?
I would look directly on the cocoon.xconf file.
I looked quickly and it looks like Lenya is using the Quartz scheduler from Cocoon.
A a consequence, you should be able to initialize your cron job directly in the cocoon.xconf by providing the correct parameters.
This will be ok only if you have a predefine number of tasks to load.
Personally I modified the QuartzScheduler so that it can read into a DB when starting Cocoon.
2) Or is it unwise to implement Contextualizable and access the request object via the ContextHelper in services which can be called from the scheduler? If yes, would that mean I should pass the request URI etc. manually?
This way all the cron Job I have already configured are automatically loaded and the correct parameters.
It enables me to create or remove tasks during my session. Those modification will reamins when cocoon restarts
I think your Idea with the ContextHelper might be fine but you need to find a way to provide the correct info to it.
3) Are there any general hints how to implement such a behaviour (call the same service from web interface and scheduler)?
Refer to my first answer. Again, I am using the QuartzScheduler directly but this system allows me to define my tasks through a URI, when Cocoon restart they are all loaded.
Thanks in advance!
-- Andreas
I hope this will help, sorry if I missed something, Pierre
