Hello,
Spring ships with a FactoryBean for the Scheduler
see
http://static.springframework.org/spring/docs/2.5.x/reference/scheduling.html#scheduling-quartz
I guess it depends on the persistence strategy your jobs have but it
could be as easy as injecting the spring managed scheduler bean
into your wicket pages and adding in the triggers/job detail directly to
that instance.
Mike
Maybe this is more question for the quartz mailing list....
Probably you would want to have only one scheduler per application, so
you should follow a singleton pattern. E.g.
public class SchedulerLocator {
private static Scheduler scheduler;
public static Scheduler getScheduler() {
if(scheduler == null) {
scheduler = .....all the factory thing.
}
return scheduler;
}
}
So everywhere you could do SchedulerLocator.getScheduler() (e.g on you
pages). I would "create" this singleton when the application object is
created or initialized.
init() {
SchedulerLocator.getScheduler();
}
If you want your jobs/triggers to persist after application restarts you
will need to create a "persistent" scheduler and consequently create the
associated tables and instruct quartz to deal with them...
Ernesto
wfroud wrote:
Hi,
I am trying to integrate a scheduler into my web application. I believe my
question is probably very trivial but I am missing some vital Java
knowledge. Please let me explain…
My web application currently allows users to choose, customise and run
reports.
I now need to add a detailed scheduler so that users can choose when to run
the reports and how often etc.
I'm using Spring for the db access, and I was going to use Quartz for
scheduling.
A basic Quartz schedule looks something like the following:
public class SimpleExample {
public void run() throws Exception {
// First we must get a reference to a scheduler
// This schedule info is stored in a db, defined in the
quartz.properties file.
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
// Add jobs and triggers to schedule.
// Start up the scheduler (nothing can actually run until the
// scheduler has been started)
sched.start();
// Wait for a short period of time so scheduler has chance to run
jobs.
sched.shutdown();
}
public static void main(String[] args) throws Exception {
SimpleExample example = new SimpleExample();
example.run();
}
}
More details about a really basic example can be found here:
http://wiki.opensymphony.com/display/QRTZ1/TutorialLesson1
I can run this fine as a standalone test.
The basics of my web application are as follows:
MyApp which extends WebApplication.
Loads of classes which extend WebPage
A MySession class which extends WebSession
What I'm not sure about is where I should be instantiating the
SchedulerFactory within my application so that all users can update any
schedule (i.e. so there is kind-of-like global access to the scheduler
object) and so that the SchedulerFactory is only instantiated the once.
I can't instantiate it in a web page as this will be user specific.
I could instantiate it in the MyApp class but then I don't have access to it
from the web pages.
Any help whatsoever, just to point me in the right direction, would be much
appreciated.
Thanks
Will
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]