Versions Compared

Key

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

...

A scheduled service is just a service component which invokes the schedule API. A service component can be built from the service component archetype - archetype — an example of such an implementation is described in Configuration Management. The basic service component implementation looks like this:

...

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.

...

The Crontab schedule used to schedule the job must be configurable. To make the Crontab expression configurable, the Configuration Management should be used. The scheduleJob method in the code example above should therefore retrieve the Crontab expression from the Configuration Management service and use that as input argument. If the Crontab expression is managed using the Configuration Management service, the schedule can be changed. However, in the code example above, a change in the schedule will not affect the jobs that are already scheduled unless the plugin is restarted manually. For that reason it is a good idea to reschedule the job if it is changed. For that purpose the Configuration Management service supports adding and removing listeners:


Code Block
themeEclipse
void myConfigurationManagement.addListener(ConfigurationManagementListener listenerthis, String relativePath)
void removeListener(ConfigurationManagementListener listenerConfigurationUtil.CONFIG_SET_NAME);
myConfigurationManagement.removeListener(this);


The implementation of the ConfigurationManagementListener can register itself on changes in the configuration set that contain the schedule and reschedule the job when there is a  change.

...