/**
  * Prepares the given jobDescriptor for execution. Returns the job that
  * will actually be run in a state ready for executing.
  *
  * Note that this is called each time a job is picked up to be executed from the cron
  * job - meaning that jobs that are paused and restarted will have 'setup()' called on them again,
  * so your job MUST detect that and act accordingly. 
  *
  * @param QueuedJobDescriptor $jobDescriptor
  *			The Job descriptor of a job to prepare for execution
  *
  * @return QueuedJob
  */
 protected function initialiseJob(QueuedJobDescriptor $jobDescriptor)
 {
     // create the job class
     $impl = $jobDescriptor->Implementation;
     $job = new $impl();
     /* @var $job QueuedJob */
     if (!$job) {
         throw new Exception("Implementation {$impl} no longer exists");
     }
     // start the init process
     $jobDescriptor->JobStatus = QueuedJob::STATUS_INIT;
     $jobDescriptor->write();
     // make sure the data is there
     $this->copyDescriptorToJob($jobDescriptor, $job);
     // see if it needs 'setup' or 'restart' called
     if (!$jobDescriptor->StepsProcessed) {
         $job->setup();
     } else {
         $job->prepareForRestart();
     }
     // make sure the descriptor is up to date with anything changed
     $this->copyJobToDescriptor($job, $jobDescriptor);
     return $job;
 }