は、あなたが持っていることができるはず、here述べたアイデアに従ってください:
public class GuaranteeSchedule implements Trigger {
private Future<?> resultForNextRun;
private TaskScheduler scheduler;
public void scheduledTask() {
// 'this' is this trigger that is used by the scheduler
// and the method `nextExecutionTime` is automatically called by the scheduler
resultForNextRun = scheduler.schedule(theTask, this);
// theTask is the object that calls something()
}
// Implementing Trigger to add control dynamic execution time of this trigger
@Override
public Date nextExecutionTime(TriggerContext tc) {
// make sure the result for the previous call is ready using the waiting feature of Future
Object result = resultForNextRun.get();
// Use tc or other stuff to calculate new schedule
return new Date();
}
}
残り、あなたは参照で述べた構成に従ってください。私は、これが前の結果のトリガーの次の呼び出しに依存する問題を解決すると信じています。また、scheduledTask
の最初の呼び出しに注意して、resultForNextRun != null
を確認する必要があります。
これは、戦略設計パターンの良い使用例です。ドキュメントを確認してくださいhttp://en.wikipedia.org/wiki/Strategy_pattern#Example – Phani
あなたはタスクスケジューリングにどのようなアプローチをしていますか?例として[this](http://darthanthony.wordpress.com/2009/07/07/dynamic-scheduling-with-javaspring/)が役に立ちます。 – nobeh
ありがとう、@nobeh。残念ながらあなたのリンクは私にはあまり役立たない、私はすでに同様のアプローチを試みたが、明らかに結果に応じてタスクを再スケジュールする方法がない。私は、SpringのQuartz SupportとSpring 3.0のScheduling Namespaceの両方を使って遊んでみました。どんな助けでも大歓迎です。ありがとう – satoshi