Switch to full style
Quartz Scheduler Examples
Post a reply

Extending Quartz Scheduler Job Interface

Sat May 25, 2013 11:25 pm

Extending Quartz Scheduler Job Interface , by implementing it using a new class named QuartzJob , and creating a new job interface which is passed to the execution function "execute", in the following example the JobDetails class is used to get the parameters passed to the current Job, the parameter in this case is our general and new Job Interface.
java code
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
* Quartz job implementation .
*/
public class QuartzJob implements Job {

private JobDetail jobDetail;

public QuartzJob() {

}

public void execute(JobExecutionContext arg0) throws JobExecutionException {
Object[] param = { arg0 };

jobDetail = arg0.getJobDetail();
if (jobDetail != null) {
JobDataMap jobDataMap = jobDetail.getJobDataMap();
if (jobDataMap != null) {
//job = (IJob) jobDataMap.get("JOB");

// job.execute();
} else {
// Do something
}

}
}

}


Following in the new IJob interface, you can extend and customize this job to meet your software requirements. it is easy task to redesign this new Job interface by adding new functions and fields. The IJob interface then can be used to in all your software model .
java code
public interface IJob {

public void execute();


public void setName(String name);
public String getName();
public String getGroup();
public void setGroup(String group);
}




Post a reply
  Related Posts  to : Extending Quartz Scheduler Job Interface
 extending enum in java     -  
 Java extending org.apache.log4j.Logger     -  
 What is an Interface? !!!!     -  
 Implement an interface in php     -  
 List interface     -  
 java interface example     -  
 Iterator interface     -  
 how to implement an interface     -  
 about Java IO-interface     -  
 methods in ActionListener interface     -