Class JobSchedulerImpl

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

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, 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(JobContext context)
      Description copied from interface: Job
      Execute this job.
      Specified by:
      execute in interface Job
      Parameters:
      context - The context of the job.
      See Also:
    • 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<ResourceChange> changes)
      Description copied from interface: ResourceChangeListener
      Report resource changes based on the filter properties of this listener.

      Note that resource changes for paths which are ancestors of the paths this listener was registered to may be reported through this method. This is due to limitations of certain resource providers to provide events on a more granular level (e.g. for deletion or movement of resources containing (potentially nested) child resources).

      Starting with version 1.2 of this API, an instance of ResoureChangeList is passed as the parameter to allow passing additional information.

      Specified by:
      onChange in interface ResourceChangeListener
      Parameters:
      changes - The changes list. This list is immutable.
      See Also: