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.
-
Field Summary
Fields inherited from interface org.apache.sling.api.resource.observation.ResourceChangeListener
CHANGE_ADDED, CHANGE_CHANGED, CHANGE_PROVIDER_ADDED, CHANGE_PROVIDER_REMOVED, CHANGE_REMOVED, CHANGES, PATHS, PROPERTY_NAMES_HINT -
Constructor Summary
ConstructorsConstructorDescriptionJobSchedulerImpl(JobManagerConfiguration configuration, org.apache.sling.commons.scheduler.Scheduler scheduler, JobManagerImpl jobManager) Create the scheduler -
Method Summary
Modifier and TypeMethodDescriptionorg.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.ScheduleBuilderCreate a schedule builder for a currently scheduled jobvoidDeactivate 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 jobsintProvide the total number of jobs registered in the system, irrespective of topicsvoidhandleEvent(org.osgi.service.event.Event event) voidvoidvoidRemove a scheduled jobvoidAdd a scheduled jobvoidsetSuspended(ScheduledJobInfoImpl info, boolean flag) Change the suspended flag for a scheduled jobvoidUnschedule a scheduled job
-
Constructor Details
-
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 Details
-
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:
-
scheduleJob
Add a scheduled job -
unscheduleJob
Unschedule a scheduled job -
removeJob
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:
-
handleEvent
public void handleEvent(org.osgi.service.event.Event event) - See Also:
-
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
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
- Specified by:
onChangein interfaceorg.apache.sling.api.resource.observation.ResourceChangeListener- See Also:
-