com.atlassian.scheduler.core.status
Class AbstractJobDetailsFactory<T>

java.lang.Object
  extended by com.atlassian.scheduler.core.status.AbstractJobDetailsFactory<T>
Type Parameters:
T - The type that the scheduler implementation uses as its internal representation of a job.
Direct Known Subclasses:
Quartz1JobDetailsFactory, Quartz2JobDetailsFactory

public abstract class AbstractJobDetailsFactory<T>
extends Object

Converts a scheduler implementation's internal representation of a job into a JobDetails. This class produces LazyJobDetails instances when the JobRunner is registered as opposed to deserializing the parameters immediately.

Since:
v1.0

Constructor Summary
protected AbstractJobDetailsFactory(AbstractSchedulerService schedulerService)
           
 
Method Summary
 JobDetails buildJobDetails(JobId jobId, T jobData, RunMode runMode)
          Transforms the scheduler's internal representation of a job into a JobDetails.
protected abstract  JobRunnerKey getJobRunnerKey(T jobData)
          Provided by the scheduler implementation to extract the job's JobRunnerKey from the scheduler's internal representation of the job.
protected abstract  Date getNextRunTime(T jobData)
          Provided by the scheduler implementation to extract the job's next scheduled run time from the scheduler's internal representation of the job.
protected abstract  Schedule getSchedule(T jobData)
          Provided by the scheduler implementation to extract the job's Schedule from the scheduler's internal representation of the job.
protected abstract  byte[] getSerializedParameters(T jobData)
          Provided by the scheduler implementation to extract the job's parameters map (in serialized form) from the scheduler's internal representation of the job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJobDetailsFactory

protected AbstractJobDetailsFactory(AbstractSchedulerService schedulerService)
Method Detail

buildJobDetails

public JobDetails buildJobDetails(@Nonnull
                                  JobId jobId,
                                  @Nonnull
                                  T jobData,
                                  @Nonnull
                                  RunMode runMode)
Transforms the scheduler's internal representation of a job into a JobDetails. This will attempt to reconstruct the job's parameters using the ClassLoader of the job's JobRunner and return an UnusableJobDetails if the job runner is not registered or its class loader cannot deserialize the parameters map.

Parameters:
jobId - the job's ID
jobData - the internal representation of the job
runMode - the expected run mode of the job
Returns:
the corresponding job details

getJobRunnerKey

@Nonnull
protected abstract JobRunnerKey getJobRunnerKey(@Nonnull
                                                        T jobData)
Provided by the scheduler implementation to extract the job's JobRunnerKey from the scheduler's internal representation of the job.

Parameters:
jobData - the scheduler's internal representation of the job
Returns:
the key for the job's target job runner

getSchedule

@Nonnull
protected abstract Schedule getSchedule(@Nonnull
                                                T jobData)
Provided by the scheduler implementation to extract the job's Schedule from the scheduler's internal representation of the job.

Parameters:
jobData - the scheduler's internal representation of the job
Returns:
the job's corresponding Schedule

getNextRunTime

@Nullable
protected abstract Date getNextRunTime(@Nonnull
                                                T jobData)
Provided by the scheduler implementation to extract the job's next scheduled run time from the scheduler's internal representation of the job.

Parameters:
jobData - the scheduler's internal representation of the job
Returns:
the job's next expected run time; may be null if the job will not be run again or if the scheduler does not provide information about future run times

getSerializedParameters

@Nullable
protected abstract byte[] getSerializedParameters(@Nonnull
                                                           T jobData)
Provided by the scheduler implementation to extract the job's parameters map (in serialized form) from the scheduler's internal representation of the job.

Parameters:
jobData - the scheduler's internal representation of the job
Returns:
a byte array containing the parameters map in serialized form; may be null, in which case an empty map will be substituted


Copyright © 2014 Atlassian. All Rights Reserved.