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.example1; 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 says "Hello" to the world. 31 * </p> 32 * 33 * @author Bill Kratzer 34 */ 35 public class HelloJob implements Job { 36 37 private static Log _log = LogFactory.getLog(HelloJob.class); 38 39 /** 40 * <p> 41 * Empty constructor for job initilization 42 * </p> 43 * <p> 44 * Quartz requires a public empty constructor so that the 45 * scheduler can instantiate the class whenever it needs. 46 * </p> 47 */ 48 public HelloJob() { 49 } 50 51 /** 52 * <p> 53 * Called by the <code>{@link org.quartz.Scheduler}</code> when a 54 * <code>{@link org.quartz.Trigger}</code> fires that is associated with 55 * the <code>Job</code>. 56 * </p> 57 * 58 * @throws JobExecutionException 59 * if there is an exception while executing the job. 60 */ 61 public void execute(JobExecutionContext context) 62 throws JobExecutionException { 63 64 // Say Hello to the World and display the date/time 65 _log.info("Hello World! - " + new Date()); 66 } 67 68 }