Class JobSchedulerImpl

java.lang.Object
org.apache.sling.event.impl.jobs.scheduling.JobSchedulerImpl
All Implemented Interfaces:
org.apache.sling.api.resource.observation.ExternalResourceChangeListener, org.apache.sling.api.resource.observation.ResourceChangeListener, org.apache.sling.commons.scheduler.Job, ConfigurationChangeListener

public class JobSchedulerImpl extends Object implements ConfigurationChangeListener, org.apache.sling.api.resource.observation.ResourceChangeListener, org.apache.sling.api.resource.observation.ExternalResourceChangeListener, org.apache.sling.commons.scheduler.Job
The scheduler for managing scheduled jobs. This is not a component by itself, it's directly created from the job manager. The job manager is also registering itself as an event handler and forwards the events to this service.
  • Constructor Details

    • JobSchedulerImpl

      public JobSchedulerImpl(JobManagerConfiguration configuration, org.apache.sling.commons.scheduler.Scheduler scheduler, JobManagerImpl jobManager)
      Create the scheduler
      Parameters:
      configuration - Central job manager configuration
      scheduler - The scheduler service
      jobManager - The job manager
  • Method Details

    • deactivate

      public void deactivate()
      Deactivate this component.
    • configurationChanged

      public void configurationChanged(boolean processingActive)
      Description copied from interface: ConfigurationChangeListener
      Notify about a configuration change.
      Specified by:
      configurationChanged in interface ConfigurationChangeListener
      Parameters:
      processingActive - true if job processing is active, otherwise false
      See Also:
    • scheduleJob

      public void scheduleJob(ScheduledJobInfoImpl info)
      Add a scheduled job
    • unscheduleJob

      public void unscheduleJob(ScheduledJobInfoImpl info)
      Unschedule a scheduled job
    • removeJob

      public void removeJob(ScheduledJobInfoImpl info)
      Remove a scheduled job
    • execute

      public void execute(org.apache.sling.commons.scheduler.JobContext context)
      Specified by:
      execute in interface org.apache.sling.commons.scheduler.Job
      See Also:
      • Job.execute(org.apache.sling.commons.scheduler.JobContext)
    • handleEvent

      public void handleEvent(org.osgi.service.event.Event event)
      See Also:
      • EventHandler.handleEvent(org.osgi.service.event.Event)
    • createJobBuilder

      public org.apache.sling.event.jobs.JobBuilder.ScheduleBuilder createJobBuilder(ScheduledJobInfoImpl info)
      Create a schedule builder for a currently scheduled job
    • getScheduledJobs

      public Collection<org.apache.sling.event.jobs.ScheduledJobInfo> getScheduledJobs(String topic, long limit, Map<String,Object>... templates)
      Get all scheduled jobs
    • getTotalNumberOfScheduledJobs

      public int getTotalNumberOfScheduledJobs()
      Provide the total number of jobs registered in the system, irrespective of topics
      Returns:
      the total number of scheduled jobs
    • setSuspended

      public void setSuspended(ScheduledJobInfoImpl info, boolean flag)
      Change the suspended flag for a scheduled job
      Parameters:
      info - The schedule info
      flag - The corresponding flag
    • addScheduledJob

      public org.apache.sling.event.jobs.ScheduledJobInfo addScheduledJob(String topic, Map<String,Object> properties, String scheduleName, boolean isSuspended, List<ScheduleInfoImpl> scheduleInfos, List<String> errors)
      Add a scheduled job
      Parameters:
      topic - The job topic
      properties - The job properties
      scheduleName - The schedule name
      isSuspended - Whether it is suspended
      scheduleInfos - The scheduling information
      errors - Optional list to contain potential errors
      Returns:
      A new job info or null
    • maintenance

      public void maintenance()
    • onChange

      public void onChange(List<org.apache.sling.api.resource.observation.ResourceChange> changes)
      Specified by:
      onChange in interface org.apache.sling.api.resource.observation.ResourceChangeListener
      See Also:
      • ResourceChangeListener.onChange(java.util.List)