KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > examples > example8 > SimpleJob


1 /*
2  * Copyright 2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 package org.quartz.examples.example8;
19
20 import java.util.Date JavaDoc;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.quartz.Job;
25 import org.quartz.JobExecutionContext;
26 import org.quartz.JobExecutionException;
27
28 /**
29  * <p>
30  * This is just a simple job that gets fired off many times by example 1
31  * </p>
32  *
33  * @author Bill Kratzer
34  */

35 public class SimpleJob implements Job {
36
37     private static Log _log = LogFactory.getLog(SimpleJob.class);
38
39     /**
40      * Empty constructor for job initilization
41      */

42     public SimpleJob() {
43     }
44
45     /**
46      * <p>
47      * Called by the <code>{@link org.quartz.Scheduler}</code> when a
48      * <code>{@link org.quartz.Trigger}</code> fires that is associated with
49      * the <code>Job</code>.
50      * </p>
51      *
52      * @throws JobExecutionException
53      * if there is an exception while executing the job.
54      */

55     public void execute(JobExecutionContext context)
56         throws JobExecutionException {
57
58         // This job simply prints out its job name and the
59
// date and time that it is running
60
String JavaDoc jobName = context.getJobDetail().getFullName();
61         _log.info("SimpleJob says: " + jobName + " executing at " + new Date JavaDoc());
62     }
63
64 }
Popular Tags