1 /* 2 * Copyright 2004-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 /* 19 * Previously Copyright (c) 2001-2004 James House 20 */ 21 package org.quartz.spi; 22 23 import org.quartz.Scheduler; 24 import org.quartz.SchedulerException; 25 26 /** 27 * <p> 28 * Provides an interface for a class to become a "plugin" to Quartz. 29 * </p> 30 * 31 * <p> 32 * Plugins can do virtually anything you wish, though the most interesting ones 33 * will obviously interact with the scheduler in some way - either actively: by 34 * invoking actions on the scheduler, or passively: by being a <code>JobListener</code>, 35 * <code>TriggerListener</code>, and/or <code>SchedulerListener</code>. 36 * </p> 37 * 38 * <p> 39 * If you use <code>{@link org.quartz.impl.StdSchedulerFactory}</code> to 40 * initialize your Scheduler, it can also create and initialize your plugins - 41 * look at the configuration docs for details. 42 * </p> 43 * 44 * <p> 45 * If you need direct access your plugin, you can have it explicitly put a 46 * reference to itself in the <code>Scheduler</code>'s 47 * <code>SchedulerContext</code> as part of its 48 * <code>{@link #initialize(String, Scheduler)}</code> method. 49 * </p> 50 * 51 * @author James House 52 */ 53 public interface SchedulerPlugin { 54 55 /* 56 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 * 58 * Interface. 59 * 60 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 */ 62 63 /** 64 * <p> 65 * Called during creation of the <code>Scheduler</code> in order to give 66 * the <code>SchedulerPlugin</code> a chance to initialize. 67 * </p> 68 * 69 * <p> 70 * At this point, the Scheduler's <code>JobStore</code> is not yet 71 * initialized. 72 * </p> 73 * 74 * <p> 75 * If you need direct access your plugin, for example during <code>Job</code> 76 * execution, you can have this method explicitly put a 77 * reference to this plugin in the <code>Scheduler</code>'s 78 * <code>SchedulerContext</code>. 79 * </p> 80 * 81 * @param name 82 * The name by which the plugin is identified. 83 * @param scheduler 84 * The scheduler to which the plugin is registered. 85 * 86 * @throws org.quartz.SchedulerConfigException 87 * if there is an error initializing. 88 */ 89 void initialize(String name, Scheduler scheduler) 90 throws SchedulerException; 91 92 /** 93 * <p> 94 * Called when the associated <code>Scheduler</code> is started, in order 95 * to let the plug-in know it can now make calls into the scheduler if it 96 * needs to. 97 * </p> 98 */ 99 void start(); 100 101 /** 102 * <p> 103 * Called in order to inform the <code>SchedulerPlugin</code> that it 104 * should free up all of it's resources because the scheduler is shutting 105 * down. 106 * </p> 107 */ 108 void shutdown(); 109 110 } 111