Results 1 to 6 of 6

Thread: Exposing the Quartz Scheduler

  1. #1
    Join Date
    Sep 2004
    Location
    Portland, OR
    Posts
    54

    Default Exposing the Quartz Scheduler

    Hi all,

    I'm trying using a SchedulerFactoryBean in my application to help schedule quartz tasks. This seems great for adding tasks with pre-defined schedules (as the documentation shows), but how does one access the internal scheduler so as to be able to add tasks to it in the future?

    My app creates jobs on the fly that are scheduled to execute in the future (and are persisted via JDBC in the interim). I can't seem to figure out how the scheduler is exposed (as a named bean would be the obvious way) for programmatic access, and that has me dead in the water for the time being.

    Thanks much for any help,
    Dolan Halbrook

  2. #2
    Join Date
    Sep 2004
    Posts
    23

    Default Re: Exposing the Quartz Scheduler

    Quote Originally Posted by dhalbrook
    Hi all,

    I'm trying using a SchedulerFactoryBean in my application to help schedule quartz tasks. This seems great for adding tasks with pre-defined schedules (as the documentation shows), but how does one access the internal scheduler so as to be able to add tasks to it in the future?

    My app creates jobs on the fly that are scheduled to execute in the future (and are persisted via JDBC in the interim). I can't seem to figure out how the scheduler is exposed (as a named bean would be the obvious way) for programmatic access, and that has me dead in the water for the time being.

    Thanks much for any help,
    Dolan Halbrook
    What do you mean "internal scheduler"? When you define a scheduler through the scheduler factory bean, you can just use it with dependency injection by declaring another bean which receives a Scheduler property and a "property" tag which sets it with a reference to the scheduler itself. You then use the scheduler api in order to set new jobs.

  3. #3
    Join Date
    Sep 2004
    Location
    Portland, OR
    Posts
    54

    Default

    Thanks for the suggestion. It sounds like what I'm describing is possible.

    Could you clarify with an example of how one would do what you described in the Spring config? I'm still a little hazy on the terminology, so that would be enormously useful.

    By "internal scheduler", i meant the scheduler that is a member of (and bootstrapped by) the SchedulerFactoryBean by default. It sounds like what you're suggesting is to override the default scheduler with my own named definition and access that instead. Would this be done by setting the "schedulerName"?

    I wasn't sure how to access what I described as the "internal scheduler" since there are no bean accessors for that scheduler in the SchedulerFactoryBean that I can see.

  4. #4
    Join Date
    Aug 2004
    Posts
    27

    Default Re: Exposing the Quartz Scheduler

    +1

    I'm trying to do the exact same thing. I have a pre-defined Job but need to create unique Triggers and JobExecutionContexts so users in my system can run the job at a frequency of their own choosing (once a day, once a week, etc) and personalized for them.

    immanuel, your response, while appreciated, doesn't help much. I'm sure it's possible - I just need a concrete example of how it's done. The SchedulerFactoryBean does not seem to expose its internal Scheduler.

    Quote Originally Posted by dhalbrook
    My app creates jobs on the fly that are scheduled to execute in the future (and are persisted via JDBC in the interim). I can't seem to figure out how the scheduler is exposed (as a named bean would be the obvious way) for programmatic access, and that has me dead in the water for the time being.

  5. #5
    Join Date
    Aug 2004
    Posts
    27

    Default

    Duh, it seems obvious in retrospect. The SchedulerFactoryBean is the QuartzScheduler object. It's a FactoryBean so the getObject method returns the QuartzScheduler object. You just define a QuartzScheduler property in your Java class and in the Spring context, set that property to the SchedulerFactoryBean.

    Quote Originally Posted by dhalbrook
    I wasn't sure how to access what I described as the "internal scheduler" since there are no bean accessors for that scheduler in the SchedulerFactoryBean that I can see.

  6. #6
    Join Date
    Sep 2004
    Location
    Portland, OR
    Posts
    54

    Default

    Good catch. Somehow I missed that going through the code of the SchedulerFactoryBean. Much clearer now. Guess I was looking for something more akin to "getScheduler".

Similar Threads

  1. Replies: 10
    Last Post: Dec 5th, 2006, 06:14 AM
  2. Quarts Scheduler Problems (again)
    By Alarmnummer in forum Container
    Replies: 1
    Last Post: Jul 29th, 2005, 03:34 AM
  3. Quartz question
    By kuns in forum Container
    Replies: 3
    Last Post: Jul 11th, 2005, 03:03 PM
  4. Replies: 2
    Last Post: May 23rd, 2005, 10:43 AM
  5. Replies: 0
    Last Post: Mar 25th, 2005, 04:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •