Java Quartz scheduler – Job Parameters

There are two ways to pass an object that can be retrieved when a Quartz job executes:

Pass the instance in the data map. When you set the job up, add your instance to the map with a key like this:

// Create job etc...
var MyClass _myInstance;
statusJob.JobDataMap.Put("myKey", _myInstance);
// Schedule job...

Retrieve the instance in the job’s Execute() method like this:

public void Execute(IJobExecutionContext context)
        {
            var dataMap = context.MergedJobDataMap;
            var myInstance = (MyClass)dataMap["myKey"];
        }

OR

Add the instance to the scheduler context when you set the job up, like this:

  ISchedulerFactory schedFact = new StdSchedulerFactory();
  _sched = schedFact.GetScheduler();
  _sched.Start();
  // Create job etc...
  var MyClass _myInstance;
  _sched.Context.Put("myKey", myInstance);
  // Schedule job...

Retrieve the instance in the job’s Execute() method like this:

public void Execute(IJobExecutionContext context)
        {
            var schedulerContext = context.Scheduler.Context;
            var myInstance = (MyClass)schedulerContext.Get("myKey");
        }

References :
http://stackoverflow.com/questions/7137960/quartz-scheduler-how-to-pass-custom-objects-as-jobparameter