develog

Quartz - Defining a Job 본문

Dev/Java

Quartz - Defining a Job

냐옴 2012. 12. 14. 15:12

Defining a Job


---------------------------------------------------------------------------------

2.1.x

---------------------------------------------------------------------------------

// A Job Class

public class PrintPropsJob implements Job {


    public PrintPropsJob() {

        // Instances of Job must have a public no-argument constructor.

    }


    public void execute(JobExecutionContext context)

            throws JobExecutionException {


        JobDataMap data = context.getMergedJobDataMap();

        System.out.println("someProp = " + data.getString("someProp"));

    }


}


// Define job instance

JobDetail job1 = newJob(MyJobClass.class)

    .withIdentity("job1", "group1")

    .usingJobData("someProp", "someValue")

    .build();



---------------------------------------------------------------------------------

2.0.x

---------------------------------------------------------------------------------

// A Job Class

public class PrintPropsJob implements Job {


    public PrintPropsJob() {

        // Instances of Job must have a public no-argument constructor.

    }


    public void execute(JobExecutionContext context)

            throws JobExecutionException {


        JobDataMap data = context.getMergedJobDataMap();

        System.out.println("someProp = " + data.getString("someProp"));

    }


}


// Define job instance

JobDetail job1 = newJob(MyJobClass.class)

    .withIdentity("job1", "group1")

    .usingJobData("someProp", "someValue")

    .build();


---------------------------------------------------------------------------------

1.x

---------------------------------------------------------------------------------

// A Job Class

public class PrintPropsJob implements Job {


    public PrintPropsJob() {

        // Instances of Job must have a public no-argument constructor.

    }


    public void execute(JobExecutionContext context)

            throws JobExecutionException {


        JobDataMap data = context.getJobDetail().getJobDataMap();

        System.out.println("someProp = " + data.getString("someProp"));

    }


}


// Define job instance

JobDetail job = new JobDetail("job1", "group1", MyJobClass.class);

job.getDataMap().put("someProp", "someValue");


'Dev > Java' 카테고리의 다른 글

poi 대용량 엑셀 write  (0) 2013.01.08
Quartz job fire manually  (0) 2012.12.18
java get ip  (0) 2012.12.14
Apache Derby Eclipse plug-in  (0) 2012.12.08
Quartz cron expression test  (0) 2012.12.04
Comments