Spring中quartz的简单例子
来源:互联网 发布:ds1100k 网络键盘 编辑:程序博客网 时间:2024/05/02 13:29
资讯首页要1个小时静态化一次,之前做法很龌龊,今天用了spring中来配置quartz。看一下简单例子吧:
- <!-- quartz配置 -->
- <bean id="indexTask" class="com.tsts168.sunyanan.app.index.support.IndexTask"></bean>
- <!-- 定义调用对象和调用对象的方法 -->
- <bean id="jobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <!-- 调用的类 -->
- <property name="targetObject">
- <ref bean="indexTask"/>
- </property>
- <!-- 调用类中的方法 -->
- <property name="targetMethod">
- <value>run</value>
- </property>
- <property name="concurrent" value="false" />
- </bean>
- <!-- 定义触发时间 -->
- <bean id="doTime" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
- <property name="jobDetail">
- <ref bean="jobtask"/>
- </property>
- <!-- repeat every 1小时 3600000 -->
- <property name="repeatInterval" value="3600000" />
- </bean>
- <!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
- <bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
- <property name="triggers">
- <list>
- <ref bean="doTime"/>
- </list>
- </property>
- </bean>
- package com.tsts168.sunyanan.app.index.support;
- import java.util.Date;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
- import com.tsts168.sunyanan.app.common.util.HtmlUtil;
- import com.tsts168.sunyanan.app.index.manager.IndexManager;
- /*
- * 首页2小时生成一次的调度
- *
- */
- public class IndexTask {
- private Log log = LogFactory.getLog(IndexTask.class);
- @SuppressWarnings("deprecation")
- public void run() {
- // 生成静态页面
- ApplicationContext scontext = new ClassPathXmlApplicationContext("applicationContext.xml");
- IndexManager manager = (IndexManager) scontext.getBean("indexManager");
- Object obj = manager.service(null);
- HtmlUtil hutil = new HtmlUtil();
- hutil.writeIndexHtml(System.getProperty("tsts.root") + "/template", System.getProperty("tsts.root"), obj);
- log.warn("生成首页at: " + (new Date()).toLocaleString());
- }
- }
- Spring中quartz的简单例子
- spring:quartz 简单例子
- Spring Quartz简单例子,定时任务
- Spring+Quartz定时任务,简单的小例子,新手完全手册
- Spring+Quartz定时任务,简单的小例子,新手完全手册
- spring+quartz 完整例子
- Spring配置Quartz例子
- Spring配置Quartz例子
- Spring配置Quartz例子
- Spring配置Quartz例子
- Spring配置Quartz例子
- spring+quartz 完整例子
- Quartz 2.2简单例子
- Spring中Quartz的配置
- Spring中Quartz的配置
- Spring中Quartz的配置
- Spring中Quartz的配置
- Spring中Quartz的配置
- 有一种感动,叫作守口如瓶
- Java位运算符号操作
- 基于prototype的动态加载js的一个类
- SSIS压缩文件并以邮件附件发送
- Sql语句学习指南
- Spring中quartz的简单例子
- shell处理字符串记录
- Hibernate中Criteria的完整用法
- 营销数据库的建设——应用洞察最大化客户价值的源动力(转)
- CRUD 是什么
- 汇编语言发展树
- QClub:敏捷在互联网时代产品研发中的实践(12.27 深圳)
- 平凡的母亲
- 在Virtualbox中安装xp导致CPU占用率100%