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.example3; 19 20 import java.util.Date; 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 * Quartz requires a public empty constructor so that the 41 * scheduler can instantiate the class whenever it needs. 42 */ 43 public SimpleJob() { 44 } 45 46 /** 47 * <p> 48 * Called by the <code>{@link org.quartz.Scheduler}</code> when a 49 * <code>{@link org.quartz.Trigger}</code> fires that is associated with 50 * the <code>Job</code>. 51 * </p> 52 * 53 * @throws JobExecutionException 54 * if there is an exception while executing the job. 55 */ 56 public void execute(JobExecutionContext context) 57 throws JobExecutionException { 58 59 // This job simply prints out its job name and the 60 // date and time that it is running 61 String jobName = context.getJobDetail().getFullName(); 62 _log.info("SimpleJob says: " + jobName + " executing at " + new Date()); 63 } 64 65 }