Spring framework Quartz configuration bean.xml example


      Click here to attend Spring Framework 4.x and certification course with a discount

    
<!-- QUARTZ configuration -->
    <bean id="AdvertPublishedJob" class="org.springframework.scheduling.quartz.JobDetailBean">
	  <property name="jobClass" value="nl.kameroom.emailservice.AdvertPublishedJob" />
	  <property name="jobDataAsMap">
    	<map>
      		<entry key="advertManager" value-ref="advertManager"/>
      		<entry key="localeMessageSource" value-ref="localeMessageSource"/>
      		<entry key="emailService" value-ref="emailService"/>
      		<entry key="userManager" value-ref="userManager"/>
    	</map>
 	 </property>	
    </bean>
	
	<bean id="AlertsJob" class="org.springframework.scheduling.quartz.JobDetailBean">
	  <property name="jobClass" value="nl.kameroom.emailservice.AlertsJob" />
	  <property name="jobDataAsMap">
    	<map>
      		<entry key="advertManager" value-ref="advertManager"/>
      		<entry key="localeMessageSource" value-ref="localeMessageSource"/>
      		<entry key="emailService" value-ref="emailService"/>
      		<entry key="userManager" value-ref="userManager"/>
      		<entry key="alertManager" value-ref="alertManager"/>
    	</map>
 	 </property>	
    </bean>
    
	<bean id="AdvertPublishedTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="AdvertPublishedJob"/>
		<property name="cronExpression" value="2 * * * * ?" />
	</bean>	
	
	<bean id="AlertsTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="AlertsJob"/>
		<property name="cronExpression" value="2 * * * * ?" />
	</bean>	
	
	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref bean="AdvertPublishedTrigger"/>
				<ref bean="AlertsTrigger"/>
			</list>
		</property>
	</bean>
	<!-- QUARTZ configuration -->
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s