Announcement Announcement Module
Collapse
No announcement yet.
Set quartz properties at runtime Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Set quartz properties at runtime

    I am trying to set some quartz properties at runtime.

    Here is a part of my xml:

    HTML Code:
    <bean id="exampleBusinessObject"
    		class="nl.group2000.sca.examples.examplequartzjob.common.ExampleBusinessObject">
    		<property name="schedulerFactory" ref="scheduler" />
    	</bean>
    
    <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    		<property name="triggers">
    			<list>
    				<ref bean="cronTrigger" />
    				<ref bean="simpleTrigger" />
    			</list>
    		</property>
    </bean>
    Code of ExampleBusinessObject:

    Code:
    private SchedulerFactoryBean schedulerFactory;
    
    public void setSchedulerFactory(SchedulerFactoryBean schedulerFactory) {
    		System.out.println("inside setSchedulerFactoryBean");
    		this.schedulerFactory = schedulerFactory;
    
    		props();
    	}
    
    	private void props()
    	{
    		Properties props = new Properties();
    		
    		props.setProperty("org.quartz.jobStore.class","org.quartz.impl.jdbcjobstore.JobStoreTX");
    				
    schedulerFactory.setQuartzProperties(props);
    The problem is the method setSchedulerFactory. From the xml I pass a SchedulerBeanFactory. However, upon execution I get:

    Cannot convert value of type [org.quartz.impl.StdScheduler] to required type [org.springframework.scheduling.quartz.SchedulerFac toryBean]

    I do understand the problem but I need a SchedulerFactorybean to be able to call the setQuartzProperties. How can I achieve this?

    Thnx in advance.

    bado

  • #2
    In your ExampleBusinessObject change the attribute from SchedulerFactoryBean to Scheduler, as,

    private Scheduler schedulerFactory;

    The rest of the code should work as fine. The native interface for Scheduler in Quartz is org.quartz.Scheduler. SchedulerFactory is a class from Spring that instantiates an object of the type Scheduler.

    HTH,
    ~ Sandy

    Comment


    • #3
      Got it! Thnx!
      Last edited by elnbado; Jan 7th, 2009, 05:03 AM.

      Comment

      Working...
      X