开发者

Quartz + Struts

I hav开发者_Go百科e a web application that using Struts + Spring + Hibernate. In this application I am getting data from a remote server in XML format, and write it to the database, when someone accesses the site, because of StrutsActions. Now I want to implement Quartz library, for writing to database does not depend on users, but I have no idea how to call an Action from Quartz.

Thanks and sorry for my english.


<bean name="archiveTask" 
    class="com.yourcompany.ArchiveTriggerTask">
</bean>

<bean id="archiveJobDetail" 
    class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
     <property name="targetObject" ref="archiveTask" />
     <property name="targetMethod" value="execute" />
</bean>

<bean id="archiveCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="archiveJobDetail" />
    <property name="cronExpression" value="0 30 10-13 ? * WED,FRI" />
</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
    <list>
        <ref bean="archiveCronTrigger" />
    </list>
</property>

You need to adjust the cronExpression to your requirement. Then create your class with execute method in it.

public class ArchiveTriggerTask   {
    public void execute()  {
            //insert your code here
    }
}

To adjust the cronExpression http://www.quartz-scheduler.org/docs/tutorial/TutorialLesson06.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜