最初に間違った質問に答えたと思うことに気づきました。後世のために以下に残します。ここでも、適切な API を見ていると仮定します。フィールドを UFkJob に追加します。
public class UfkJob implements IScheduledJob {
String jobName = null;
public void execute(ISchedulingService service) {
if (... && jobName != null) {
/* here i want to remove the current running job */
ISchedulingService service = (ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME);
service.removeScheduledJob(jobName);
}
public void setJobName(String name){
this.jobName = name;
}
}
そして、ジョブをスケジュールするとき:
ISchedulingService service = (ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME);
UfkJob job = new UfkJob();
job.setJobName(service.addScheduledJobAfterDelay(5000, job, 200));
または、いつでもジョブ スケジュール自体を使用できます。
public class UfkJob implements IScheduledJob {
String jobName;
ISchedulingService service;
public UfkJob(ISchedulingService service){
this.service = service;
this.jobName = service.addScheduledJobAfterDelay(5000, this, 200);
}
public void execute(ISchedulingService service) {
if (...) {
service.removeScheduledJob(jobName);
}
}
}
//Your calling code
...
new UfkJob((ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME));
----- 以下の私の最初の回答は、間違った質問だと思います ----
適切なライブラリの API ドキュメントを見ているかどうかはわかりませんが、メソッド呼び出しは次のとおりです。
service.addScheduledJobAfterDelay(5000,new UfkJob(),200);
と定義されている:
addScheduledJobAfterDelay(int interval, IScheduledJob job, int delay) 指定された遅延後に開始される定期的な実行のジョブをスケジュールします。
鍵は「定期的な実行」です。あなたが探しているのは次のように聞こえます:
addScheduledOnceJob(long timeDelta, IScheduledJob job) 将来の単一実行のためにジョブをスケジュールします。
したがって、あなたの呼び出しは次のようになります。
service.addScheduledOnceJob(5000, new UfkJob());
これにより、メソッド呼び出しの 5 秒後に UfkJob が 1 回実行されます。