View Javadoc

1   /*
2    * #%L
3    * Bitrepository Integrity Client
4    * 
5    * $Id$
6    * $HeadURL$
7    * %%
8    * Copyright (C) 2010 - 2011 The State and University Library, The Royal Library and The State Archives, Denmark
9    * %%
10   * This program is free software: you can redistribute it and/or modify
11   * it under the terms of the GNU Lesser General Public License as 
12   * published by the Free Software Foundation, either version 2.1 of the 
13   * License, or (at your option) any later version.
14   * 
15   * This program is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   * GNU General Lesser Public License for more details.
19   * 
20   * You should have received a copy of the GNU General Lesser Public 
21   * License along with this program.  If not, see
22   * <http://www.gnu.org/licenses/lgpl-2.1.html>.
23   * #L%
24   */
25  package org.bitrepository.service.scheduler;
26  
27  import org.bitrepository.service.workflow.JobID;
28  import org.bitrepository.service.workflow.JobTimerTask;
29  import org.bitrepository.service.workflow.SchedulableJob;
30  
31  import java.util.Date;
32  
33  /**
34   * Interface for scheduling jobs for services.
35   */
36  public interface JobScheduler {
37      /**
38       * Adds a job for the scheduler to schedule.
39       * @param job The jo to schedule.
40       * @param interval The interval for how often the workflow should be triggered.
41       */
42      void schedule(SchedulableJob job, Long interval);
43  
44      /**
45       * Cancels the workflow with the given name.
46       *
47       * @param jobId The ID of the workflow to cancelJob.
48       * @return The canceled JobTimerTask.
49       */
50      JobTimerTask cancelJob(JobID jobId);
51  
52  
53      /**
54       * Reschedules the job to start now,
55       * @param job
56       * @return A string indicating the result of the attempt to start the workflow.
57       */
58      String startJob(SchedulableJob job);
59  
60      /**
61       * Return the date for the next run of the indicated workflow. Return null if the workflow isn't scheduled.
62       */
63      Date getNextRun(JobID jobId);
64  
65      /**
66       * Returns the interval between runs for the indicated workflow. The interval is in milliseconds.
67       */
68      long getRunInterval(JobID jobId);
69  
70      /**
71       * Enables other objects to listen for job events.
72       * @param listener The callback listener to receive the events.
73       */
74      void addJobEventListener(JobEventListener listener);
75  }