Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEclipse
public class CustomJobServiceImpl extends SimpleServiceComponent implements CustomJobService {
	   public void onStart() {
      // Run the job only on the master and not on the read-only slaves
       if (myJcrRepositoryService.isReadOnly()) {
	}
	
          LOG.warning("This cluster is read only. This job is only executed on the master. Job '" + JOB_NAME + "' not scheduled.");
          return;
   }
   public void onStop() {
	}
	      // Stop listening to update events on the schedule
      myConfigurationManagement.removeListener(this);

      // Remove the job from the schedule
      unscheduleJob();
   }
   public void run(SchedulerJob job) {
      // Check whether this instance is the cluster task master
      if (!myFrameworkConfig.isClusterTaskMaster()) {
	}
}
         LOG.log(Level.INFO, "Execution of job '" + JOB_NAME + "' skipped on this server.");
         return;
      }
}     



Note

The CustomJobService is the interface that identifies this service and is registered as the interface classname in the Activator. The run method is the method that should be invoked on each moment according to the time schedule. The onStart and onStop methods are invoked for starting/stopping the plugin and are thus the most suitable locations to schedule/unscheduled the task.

...