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的更多相关文章

  1. Quartz Scheduler(2.2.1) - Usage of Calendars

    Quartz Calendar objects (not java.util.Calendar objects) can be associated with triggers at the time ...

  2. 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 ...

  3. 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 ...

  4. Table of Contents - Quartz Scheduler

    Getting Started Hello World Integration with Spring Quartz Scheduler Developer Guide Usage of JobDat ...

  5. spring集成quartz scheduler

    创建项目 有两种创建quart配置作业 1.使用MethodInvokingJobDetailFactoryBean  Quartz Scheduler 配置作业(MethodInvokingJobD ...

  6. Quartz Scheduler 开发指南(1)

    Quartz Scheduler 开发指南(1) 原文地址:http://www.quartz-scheduler.org/generated/2.2.2/html/qtz-all/ 实例化调度程序( ...

  7. 最新 Spring 4.2.2 集成 Quartz Scheduler 2.2.2 任务调度示例

    参考http://blog.csdn.net/defonds/article/details/49496895 本文将演示如何通过 Spring 使用 Quartz Scheduler 进行任务调度. ...

  8. Quartz Scheduler(2.2.1) - hello world

    简单示例 1. maven 依赖 <dependencies> <dependency> <groupId>org.quartz-scheduler</gro ...

  9. 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 ...

随机推荐

  1. java tools: jmap

    SYNOPSIS jmap [ option ] pid click here to see detail DESCRIPTION jmap prints shared object memory m ...

  2. 关于名称重整(name mangling)、多态性的一些简单介绍

    在看GCC源码的时候看到mangles这个单词,于是google了一下. 在面向对象编程语言出现之前,如果你想要打印不同类型的数据,需要写多个方法,例如PrintInteger(int i),Prin ...

  3. Jstl标签的使用

    一. 配置 JSTL 包括两个 JAR 文件, jstl.jar 和 standard.jar .是什么没有必要管,重在应用( 1+1 ? =2 ,我们没有必要深究,只需要知道这么用就行.). 原文引 ...

  4. Python3爬取百度百科(配合PHP)

    用PHP写了一个网页,可以获取百度百科词条.源代码已分享至github:https://github.com/1049451037/xiaobaike/tree/master 那么通过Python来爬 ...

  5. Enhancing the Scalability of Memcached

    原文地址: https://software.intel.com/en-us/articles/enhancing-the-scalability-of-memcached-0 1 Introduct ...

  6. 关于ant的使用和入门知识

    入门技术 在学习struts+spring+hibernate,尤其是Appfuse的过程中大量涉及到ant的使用,因此我觉得有必要对ant做个比较深入的学习,以下是在学习过程中搜集的材料.比较详细, ...

  7. Posting data to a HttpHandler greater then ~29MB gives a 404 error

    1down votefavorite 1 I am testing a HttpHandler that accepts XML. It works fine when a small amount ...

  8. 关于.net中线程原子性的自我总结

    首先来张图,一张 cpu的简图,仅从个人理解角度理解画的 大体 解释下这张图 这是 一张 i5的简图i5 大家都知道 是双核四线程,(超线程技术)l1,l2,l3是 1,2,3级缓存. Cpu工作:每 ...

  9. Spring的DataSource配置、将Hibernate配置所有写到Spring配置

    DataSource能够集中管理数据库连接,降低维护工作量,使部署更简单: Spring的DataSource配置:(Spring数据源配置)这里使用dbcp,还有非常多其它的如c3p0,jdbc,j ...

  10. mongo批量更新

    update的如果要批量更新是无能为力的,如果有多条匹配的结果,但结果是只能更新一条. 用bulk来进行处理 var bulk = db.HIS_ALARM.initializeUnorderedBu ...