https://github.com/Dreampie/jfinal-quartz jfinal-quartz异步执行任务:
<dependency>
<groupId>cn.dreampie</groupId>
<artifactId>jfinal-quartz</artifactId>
<version>${jfinal-quartz.version}</version>
</dependency>
目前刚刚发布第2个版本0.2:
<jfinal-quartz.version>0.2</jfinal-quartz.version>
使用方法:
jfinal config配置
//quartz start plugin
plugins.add(new QuartzPlugin());
//write job
public class DemoJob implements Job {
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
//get param from job
Map data = jobExecutionContext.getJobDetail().getJobDataMap();
System.out.println("hi,"+data.get("name")+"," + new Date().getTime());
}
}
//start it
//quartzKey must different every task
//addParam to add param in job
//run cron
new QuartzCronJob(new QuartzKey(1, "test", "test"), "*/5 * * * * ?", DemoJob.class)
.addParam("name", "quartz").start();
//run once
new QuartzOnceJob(new QuartzKey(2, "test", "test"), new Date(), DemoJob.class)
.addParam("name", "quartz").start();
或者在resource目录先quartz文件夹 创建quartz配置文件quartz.properties和任务列表文件jobs.properties
job.channel.class=cn.dreampie.DemoJob
job.channel.group=channel
job.channel.id=1
job.channel.cron=*/5 * * * * ?
job.channel.enable=false #是否执行该任务
quartz插件或自动搜索并执行该任务
https://github.com/Dreampie?tab=repositories 目录下有多款插件:
cn.dreampie.jfinal-shiro https://github.com/Dreampie/jfinal-shiro shiro插件
cn.dreampie.jfinal-shiro-freemarker https://github.com/Dreampie/jfinal-shiro-freemarker shiro插件实现的freemarker标签库
cn.dreampie.jfinal-web https://github.com/Dreampie/jfinal-web 相关web插件,简洁model实现
cn.dreampie.jfinal-utils https://github.com/Dreampie/jfinal-utils 部分jfinal工具
cn.dreampie.jfinal-tablebind https://github.com/Dreampie/jfinal-tablebind jfinal的table自动绑定插件,支持多数据源
cn.dreampie.jfinal-flyway https://github.com/Dreampie/jfinal-flyway 数据库脚本升级插件,开发中升级应用时,使用脚本同步升级数据库或者回滚
cn.dreampie.jfinal-captcha https://github.com/Dreampie/jfinal-captcha 基于jfinal render的超简单验证吗插件
cn.dreampie.jfinal-quartz https://github.com/Dreampie/jfinal-quartz 基于jfinal 的quartz管理器
cn.dreampie.jfinal-sqlinxml https://github.com/Dreampie/jfinal-sqlinxml 基于jfinal 的类似ibatis的sql语句管理方案
cn.dreampie.jfinal-lesscss https://github.com/Dreampie/jfinal-lesscss java实现的lesscsss实时编译插件,可以由于jfinal
cn.dreampie.jfinal-coffeescript https://github.com/Dreampie/jfinal-coffeescript java实现的coffeescript实时编译插件,可以由于jfinal
cn.dreampie.jfinal-akka https://github.com/Dreampie/jfinal-akka java使用akka执行异步任务
cn.dreampie.jfinal-mailer https://github.com/Dreampie/jfinal-mailer 使用akka发布邮件的jfinal插件
cn.dreampie.jfinal-slf4j https://github.com/Dreampie/jfinal-slf4j 让jfinal使用slf4j的日志api
部分内容借鉴了网络资料