cancel
Showing results for 
Search instead for 
Did you mean: 

Adding jobs to Scheduler - schedulerFactory bean

jamen
Confirmed Champ
Confirmed Champ
Hi,

I am looking into implementing some custom functionality involving the addition of jobs to the scheduler (quartz).  In the scheduled-jobs-context.xml file there is a bean - "schedulerFactory" as shown below

   <!– Scheduled tasks –>
    <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="tempFileCleanerTrigger" />


I was just wondering whether anyone knows how or whether I can get access to this bean so I can add more triggers to it on demand (through a  web interface).

Cheers
Jamen
3 REPLIES 3

andy
Champ on-the-rise
Champ on-the-rise
Hi

The normal way is to schedule jobs in the config.
In code, you can obtain the bean and schudule anything.

The scheduler is not exposed as a service or web service at the moment.

Regards

Andy

jamen
Confirmed Champ
Confirmed Champ
Hi,

I am familiar with adding jobs through the config, but in particular case I will be doing it through code.  Out of interest, are there any development resources on how to get the relevant beans in code (I couldn't find anything in the wiki so far).  I am unsure of the application context or the specific classes to use to do a getBean() call.

Jamen

andy
Champ on-the-rise
Champ on-the-rise
Hi

You need to define a bean into which you would then inject the scheduler.
You can then use the scheduler bean to schedule jobs.
(You will get an org.quartz.Scheduler as this may not be clear)

You can use another Scheduler (identified by name, rather than the default) by defining another SchedulerFactoryBean. See the documentation for SchedulerFactoryBean.

You can get hold of other beans by name if your bean implements the BeanFactoryAware interface. Then you get access to the BeanFactory. Most beans are configured by injection rather than looking up beans this way. See the interfaces in the Spring org.springframework.beans.factory package for more details.


Cheers

Andy