가이드 제목은 [도구명] [내용]-하기 형태(ex Bitbucket Cloud 저장소 생성하기)로 입력한다.
이 문서에 대한 요약 /개요를 입력한다. (구글에서 검색되었을때 표시되는 문장)
이 문서는 Java에서 Jira Scheduler를 구현하는 방법을 공유하기 위해 작성되었다.
가이드에 사용되는 도구 정보를 입력한다.
|
첨부한 이미지 너비는 800px 을 넘기지 않는다.
@ExportAsService @Named public class ScheduleSync implements LifecycleAware { @ComponentImport private final SchedulerService schedulerService; private final JobId ISSUE_SYNC_JOB_ID = JobId.of("issue-sync-job-id"); @Override public void onStart() { issueSyncService.doLogin(); JobConfig jobConfig = JobConfig.forJobRunnerKey(ScheduleJob.ISSUE_SYNC_JOBRUNNER_KEY) .withSchedule(Schedule.forCronExpression((String) getDbInfo1().get("cron"))) .withRunMode(RunMode.RUN_LOCALLY); schedulerService.scheduleJob(ISSUE_SYNC_JOB_ID, jobConfig); } @Override public void onStop() { schedulerService.unscheduleJob(ISSUE_SYNC_JOB_ID); } } |
public void controlJob() throws SchedulerServiceException { if(getDbInfo1().get("scheduleJob").equals("on")){ doJob(); }else if(getDbInfo1().get("scheduleJob").equals("off") || getDbInfo1().get("scheduleJob") == null){ stopJob(); } } |
public class ScheduleJob implements JobRunner { public static final JobRunnerKey ISSUE_SYNC_JOBRUNNER_KEY = JobRunnerKey.of(ScheduleJob.class.getCanonicalName()); } public class ScheduleSync implements LifecycleAware { private final JobId ISSUE_SYNC_JOB_ID = JobId.of("issue-sync-job-id"); JobConfig jobConfig = JobConfig.forJobRunnerKey(ScheduleJob.ISSUE_SYNC_JOBRUNNER_KEY) .withSchedule(Schedule.forCronExpression((String) getDbInfo1().get("cron"))) .withRunMode(RunMode.RUN_LOCALLY); schedulerService.scheduleJob(ISSUE_SYNC_JOB_ID, jobConfig); } |