Class JobSchedulerImpl
java.lang.Object
org.apache.sling.event.impl.jobs.scheduling.JobSchedulerImpl
- All Implemented Interfaces:
ExternalResourceChangeListener,ResourceChangeListener,Job,ConfigurationChangeListener
public class JobSchedulerImpl
extends Object
implements ConfigurationChangeListener, ResourceChangeListener, ExternalResourceChangeListener, 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, 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(JobContext context) Execute this job.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) voidvoidonChange(List<ResourceChange> changes) Report resource changes based on the filter properties of this listener.voidRemove 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, 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
Description copied from interface:JobExecute this job. -
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
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
Description copied from interface:ResourceChangeListenerReport 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
ResoureChangeListis passed as the parameter to allow passing additional information.- Specified by:
onChangein interfaceResourceChangeListener- Parameters:
changes- The changes list. This list is immutable.- See Also:
-