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 Summary
Constructors Constructor Description JobSchedulerImpl(JobManagerConfiguration configuration, org.apache.sling.commons.scheduler.Scheduler scheduler, JobManagerImpl jobManager)Create the scheduler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.sling.event.jobs.ScheduledJobInfoaddScheduledJob(String topic, Map<String,Object> properties, String scheduleName, boolean isSuspended, List<ScheduleInfoImpl> scheduleInfos, List<String> errors)Add a scheduled jobvoidconfigurationChanged(boolean processingActive)Notify about a configuration change.org.apache.sling.event.jobs.JobBuilder.ScheduleBuildercreateJobBuilder(ScheduledJobInfoImpl info)Create a schedule builder for a currently scheduled jobvoiddeactivate()Deactivate this component.voidexecute(org.apache.sling.commons.scheduler.JobContext context)Collection<org.apache.sling.event.jobs.ScheduledJobInfo>getScheduledJobs(String topic, long limit, Map<String,Object>... templates)Get all scheduled jobsintgetTotalNumberOfScheduledJobs()Provide the total number of jobs registered in the system, irrespective of topicsvoidhandleEvent(org.osgi.service.event.Event event)voidmaintenance()voidonChange(List<org.apache.sling.api.resource.observation.ResourceChange> changes)voidremoveJob(ScheduledJobInfoImpl info)Remove a scheduled jobvoidscheduleJob(ScheduledJobInfoImpl info)Add a scheduled jobvoidsetSuspended(ScheduledJobInfoImpl info, boolean flag)Change the suspended flag for a scheduled jobvoidunscheduleJob(ScheduledJobInfoImpl info)Unschedule a scheduled job
-
-
-
Constructor Detail
-
JobSchedulerImpl
public JobSchedulerImpl(JobManagerConfiguration configuration, org.apache.sling.commons.scheduler.Scheduler scheduler, JobManagerImpl jobManager)
Create the scheduler- Parameters:
configuration- Central job manager configurationscheduler- The scheduler servicejobManager- The job manager
-
-
Method Detail
-
deactivate
public void deactivate()
Deactivate this component.
-
configurationChanged
public void configurationChanged(boolean processingActive)
Description copied from interface:ConfigurationChangeListenerNotify about a configuration change.- Specified by:
configurationChangedin interfaceConfigurationChangeListener- Parameters:
processingActive-trueif job processing is active, otherwisefalse- See Also:
ConfigurationChangeListener.configurationChanged(boolean)
-
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:
executein interfaceorg.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 infoflag- 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 topicproperties- The job propertiesscheduleName- The schedule nameisSuspended- Whether it is suspendedscheduleInfos- The scheduling informationerrors- 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:
onChangein interfaceorg.apache.sling.api.resource.observation.ResourceChangeListener- See Also:
ResourceChangeListener.onChange(java.util.List)
-
-