2 * Copyright (C) 2005 uguu, All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Clarkware Consulting, Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without prior written permission. For written
18 * permission, please contact clarkware@clarkware.com.
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 * CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 package jp.gr.java_conf.uguu.scheduler;
33 import java.io.Serializable;
38 * スケジューラでタスクを実行するには、このインターフェイスを実装し、トリガーとともにスケジュールを作成してスケジューラに登録します。
41 * タスクは、スケジューラによって、複数のスレッドで同じインスタンスの {@link #task(Schedule, TaskEvent)} メソッドが呼び出される可能性があります。
42 * 例えば、タスクの実行に 1 分以上かかるとして、そのタスクを 10 秒間隔で呼び出した場合、前回のタスクが完了する前にタスクが呼び出される可能性があります。
43 * タスクの実装は、その点に注意してください。
46 * タスクは、永続化のために、直列化可能である必要があります。
48 * @param <T> タスクの実行結果の型。
51 public interface Task<T> extends Serializable {
55 * タスクの実行結果を返すことができますが、何も返さない場合は null を返すこともできます。
56 * また、タスクが失敗した場合、自由に例外をスローすることができます。
57 * 重大な問題は発生しなかったが通常終了でもない場合、 {@link WarningException} 例外をスローしてください。
59 * @param schedule スケジュール。
60 * @param event タスクの実行のイベント情報。
62 * @throws WarningException 警告で終了した場合。
63 * @throws Exception タスクが失敗した場合。
65 T task(Schedule schedule, TaskEvent event) throws Exception;