Announcement Announcement Module
No announcement yet.
programatical creation of SchedluerFactoryBean bean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • programatical creation of SchedluerFactoryBean bean

    So I'd like to use this scheduler bean to run jobs at runtime.

    I create the bean as such and set its triggers and listeners.
    When I do a start() nothing happens. I tried doing a getObject() and casting to StdSchedluer and then call start() but it throws a NPE.

    schedulerFactory = new SchedulerFactoryBean();
    schedulerFactory.setTriggers( triggers );
    schedulerFactory.setSchedulerListeners( listener );

    I ensure triggers and listeners are in existance before setting them on the factory bean.

    What am I doing wrong ?

    thanks much.

  • #2
    Also, please note that if I leave the factory bean setup in the config xml file and instead try to get the schedluer as such from the factory:

    Scheduler scheduler = (Scheduler) ctx.getBean( "scheduler" );
    try {
    } catch (SchedulerException e) {
    e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.

    this results in my jobDetail being called multiple times, depending on the number of times I execute the above code.

    is there some sort of scheduler reset() function ? nothing shows up in the API for this.



    • #3
      If you're using the SchedulerFactoryBean programmatically, you will need to invoke the afterPropertiesSet() method to create the Scheduler instance and start the scheduler (you can call setAutoStartup(false) if you don't want the scheduler to start automatically). You can then call getObject() to get the Scheduler instance.


      • #4
        It worked. Thanks you very much.