Hi .. i am using spring + struts to make an application using Eclipse.
i facing a problem with using spring quartz in tomcat.
i follow example give by
http://home.ustc.edu.cn/~lwp2003/boo.../html/114.html
i am using simpletrigger.
i found 1 problem is , when my project name is ROOT , it seem like the trigger will fired twice , if the project name not ROOT, this not going to be a problem.
below is my code:
applicationcontext.xml
simplejob.javaCode:<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="job" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass"> <value>com.apress.prospring.ch14.quartz.MessageJob</value> </property> <property name="jobDataAsMap"> <map> <entry key="message"> <value>This is a message from the Spring configuration file! </value> </entry> </map> </property> </bean> <bean id="trigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail"> <ref local="job"/> </property> <property name="startDelay"> <value>1000</value> </property> <property name="repeatInterval"> <value>3000</value> </property> </bean> <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref local="trigger"/> </list> </property> </bean> </beans>
Code:package com.apress.prospring.ch14.quartz; import java.util.Map; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; public class MessageJob implements Job { public void execute(JobExecutionContext context) throws JobExecutionException { Map properties = context.getJobDetail().getJobDataMap(); System.out.println("Previous Fire Time: " + context.getPreviousFireTime()); System.out.println("Current Fire Time: " + context.getFireTime()); System.out.println("Next Fire Time: " + context.getNextFireTime()); System.out.println(properties.get("message")); System.out.println(""); } }


Reply With Quote