Quartz Scheduler(2.2.1) - Usage of JobDataMap
The JobDataMap can be used to hold any amount of (serializable) data objects which you wish to have made available to the job instance when it executes. JobDataMap is an implementation of the Java Map interface, and has some added convenience methods for storing and retrieving data of primitive types.
Here's some snippets of putting data into the JobDataMap while defining/building the JobDetail, prior to adding the job to the scheduler:
JobDetail jobDetail = JobBuilder.newJob(HelloJob.class)
.withIdentity("helloJob", Scheduler.DEFAULT_GROUP)
.usingJobData("msg", "hello JobDataMap.")
.build();
Here is an example of getting data from the JobDataMap during the job's execution:
public class HelloJob implements Job {
public void execute(JobExecutionContext context) throws JobExecutionException {
String msg = context.getJobDetail().getJobDataMap().getString("msg");
System.out.println("msg: " + msg);
}
}
If you add setter methods to your job class that correspond to the names of keys in the JobDataMap (such as a setMsg(String msg) method for the data in the example above), then Quartz's default JobFactory implementation will automatically call those setters when the job is instantiated, thus preventing the need to explicitly get the values out of the map within your execute method.
public class HelloJob implements Job {
@Setter
private String msg;
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("msg: " + msg);
}
}
Quartz Scheduler(2.2.1) - Usage of JobDataMap的更多相关文章
- Quartz Scheduler(2.2.1) - Usage of Calendars
Quartz Calendar objects (not java.util.Calendar objects) can be associated with triggers at the time ...
- Quartz Scheduler(2.2.1) - Usage of SimpleTrigger
SimpleTrigger should meet your scheduling needs if you need to have a job execute exactly once at a ...
- Quartz Scheduler(2.2.1) - Usage of CronTriggers
Cron is a UNIX tool that has been around for a long time, so its scheduling capabilities are powerfu ...
- Table of Contents - Quartz Scheduler
Getting Started Hello World Integration with Spring Quartz Scheduler Developer Guide Usage of JobDat ...
- spring集成quartz scheduler
创建项目 有两种创建quart配置作业 1.使用MethodInvokingJobDetailFactoryBean Quartz Scheduler 配置作业(MethodInvokingJobD ...
- Quartz Scheduler 开发指南(1)
Quartz Scheduler 开发指南(1) 原文地址:http://www.quartz-scheduler.org/generated/2.2.2/html/qtz-all/ 实例化调度程序( ...
- 最新 Spring 4.2.2 集成 Quartz Scheduler 2.2.2 任务调度示例
参考http://blog.csdn.net/defonds/article/details/49496895 本文将演示如何通过 Spring 使用 Quartz Scheduler 进行任务调度. ...
- Quartz Scheduler(2.2.1) - hello world
简单示例 1. maven 依赖 <dependencies> <dependency> <groupId>org.quartz-scheduler</gro ...
- Quartz Scheduler(2.2.1) - Working with JobStores
About Job Stores JobStores are responsible for keeping track of all the work data you give to the sc ...
随机推荐
- HDU 3665 Seaside (最短路,Floyd)
题意:给定一个图,你家在0,让你找出到沿海的最短路径. 析:由于这个题最多才10个点,那么就可以用Floyd算法,然后再搜一下哪一个是最短的. 代码如下: #pragma comment(linker ...
- [转]JSON.stringify 语法实例讲解
原文地址:http://www.jb51.net/article/29893.htm 作用:这个函数的作用主要是为了系列化对象的. 可能有些人对系列化这个词过敏,我的理解很简单.就是说把原来是对象的类 ...
- arcgis下载
你懂的~ t.cn/RA4cc3k 密码ygdr 包含10.2全部,含有(亲测)字样表示测试过OK的,SP是从esri网站下载的几乎全部patch和sp,包括desktop.engine和sever: ...
- Linux下Vim工具常用命令
原文地址: http://www.cnblogs.com/lizhenghn/p/3675011.html 在linux下做开发,甚至是只做管理维护工作,也少不了Vim的使用.作为一个新手,我也是刚刚 ...
- Exchange模式功能
Exchange模式: Outlook中的投票功能: 新建邮件--选项--使用投票按钮
- Codeforces Gym 100733J Summer Wars 线段树,区间更新,区间求最大值,离散化,区间求并
Summer WarsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.a ...
- Codeforces Gym 100425H H - Football Bets 构造
H - Football BetsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- 用adb pull命令从android系统中读取文件失败的原因及解决办法
问题:使用adb pull命令从android系统中读取文件失败.显示:Permission denied 原因:是由于文件权限原因引起. 使用ls -l命令查看android系统中的 ...
- cocos2dx 3.1从零学习(一)——入门篇(一天学会打飞机)
没办法,浏览这么高,为啥没人投票呢?朋友们,我这篇文章參加了csdn博文大赛.喜欢的来点个赞吧!点击:http://vote.blog.csdn.net/Article/Details?article ...
- auto_ptr解析
auto_ptr是当前C++标准库中提供的一种智能指针,或许相对于boost库提供的一系列眼花缭乱的智能指针, 或许相对于Loki中那个无所不包的智能指针,这个不怎么智能的智能指针难免会黯然失色.诚然 ...