Results 1 to 3 of 3

Thread: How do I startup quartz scheduler manually with SchedulerFactoryBean?

  1. #1

    Default How do I startup quartz scheduler manually with SchedulerFactoryBean?

    I configure quartz scheduler using Spring SchedulerFactoryBean like this:

    Code:
        <bean
            class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <property name="triggers">
                <list>
                    <ref bean="someTrigger" />
                </list>
            </property>
            <property name="jobFactory" ref="jobFactory" />
            <property name="schedulerContextAsMap">
                <map>
                    <entry key="somService" value-ref="somService" />
                </map>
            </property>
            <property name="dataSource" ref="dataSource" />
            <property name="transactionManager" ref="transactionManager" />
            <property name="autoStartup" value="false" />
        </bean>
    Note the autoStartup = false, I want to start up the scheduler manually by calling the Scheduler.

    How do I get handle to the created scheduler? I want to inject into some other bean, where I trigger the scheduler to start.

    SchedulerFactoryBean implements FactoryBean, and method public Object getObject() { return this.scheduler; }, so this is somehow related to the answer I guess.

  2. #2
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    When you inject your SchedulerFactoryBean into another bean, not schedule factory, but scheduler created by is injected.

  3. #3

    Default

    Quote Originally Posted by al0 View Post
    When you inject your SchedulerFactoryBean into another bean, not schedule factory, but scheduler created by is injected.
    Ah, ok. Thanks. Now I have

    Code:
        <bean id="scheduler" 
            class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <property name="triggers">
            ...
        </bean>
    
        <bean id="schedulerStarterBean" class="...">
           <property name="scheduler" ref="scheduler" />
        </bean>
    and this works.

Posting Permissions

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