Package org.nuxeo.ecm.core.scheduler
Class SchedulerServiceImpl
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.core.scheduler.SchedulerServiceImpl
-
- All Implemented Interfaces:
SchedulerService
,Adaptable
,Component
,Extensible
,TimestampedService
public class SchedulerServiceImpl extends DefaultComponent implements SchedulerService
Schedule service implementation. Since the cleanup of the quartz job is done when service is activated, ( see see https://jira.nuxeo.com/browse/NXP-7303 ) in cluster mode, the schedules contributions MUST be the same on all nodes. Due the fact that all jobs are removed when service starts on a node it may be a short period with no schedules in quartz table even other node is running.
-
-
Field Summary
Fields Modifier and Type Field Description static Duration
CLUSTER_START_DURATION_DEFAULT
static String
CLUSTER_START_DURATION_PROP
protected RuntimeContext
context
protected ScheduleExtensionRegistry
registry
protected org.quartz.Scheduler
scheduler
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description SchedulerServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate(ComponentContext context)
Activates the component.void
deactivate(ComponentContext context)
Deactivates the component.RuntimeContext
getContext()
boolean
hasApplicationStarted()
Checks if the framework has fully started.void
registerExtension(Extension extension)
Registers the given extension.void
registerSchedule(Schedule schedule)
Registers a schedule.void
registerSchedule(Schedule schedule, Map<String,Serializable> parameters)
Registers a schedule.protected void
schedule(String id, org.quartz.JobDetail job, org.quartz.Trigger trigger)
protected void
schedule(Schedule schedule, Map<String,Serializable> parameters)
protected void
setupScheduler()
protected void
shutdownScheduler()
void
start(ComponentContext context)
Start the component.protected void
startScheduler()
void
stop(ComponentContext context)
Stop the component.void
unregisterExtension(Extension extension)
Unregisters the given extension.boolean
unregisterSchedule(String id)
UnRegisters a schedule.boolean
unregisterSchedule(Schedule schedule)
UnRegisters a schedule.protected boolean
unschedule(String id)
protected boolean
unschedule(String id, org.quartz.JobKey jobKey)
-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, setLastModified, setModifiedNow, setName, unregister, unregisterContribution
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
CLUSTER_START_DURATION_PROP
public static final String CLUSTER_START_DURATION_PROP
- Since:
- 11.1
- See Also:
- Constant Field Values
-
CLUSTER_START_DURATION_DEFAULT
public static final Duration CLUSTER_START_DURATION_DEFAULT
- Since:
- 11.1
-
context
protected RuntimeContext context
-
scheduler
protected org.quartz.Scheduler scheduler
-
registry
protected final ScheduleExtensionRegistry registry
-
-
Constructor Detail
-
SchedulerServiceImpl
public SchedulerServiceImpl()
-
-
Method Detail
-
activate
public void activate(ComponentContext context)
Description copied from interface:Component
Activates the component.This method is called by the runtime when a component is activated.
- Specified by:
activate
in interfaceComponent
- Overrides:
activate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
setupScheduler
protected void setupScheduler() throws IOException, org.quartz.SchedulerException
- Throws:
IOException
org.quartz.SchedulerException
-
shutdownScheduler
protected void shutdownScheduler()
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
start
public void start(ComponentContext context)
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
startScheduler
protected void startScheduler()
-
stop
public void stop(ComponentContext context)
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
-
hasApplicationStarted
public boolean hasApplicationStarted()
Description copied from interface:SchedulerService
Checks if the framework has fully started.Used to delay job execution until the framework has fully started.
- Specified by:
hasApplicationStarted
in interfaceSchedulerService
- Returns:
true
if the framework has started
-
registerExtension
public void registerExtension(Extension extension)
Description copied from interface:Extensible
Registers the given extension.- Specified by:
registerExtension
in interfaceExtensible
- Overrides:
registerExtension
in classDefaultComponent
- Parameters:
extension
- the extension to register
-
unregisterExtension
public void unregisterExtension(Extension extension)
Description copied from interface:Extensible
Unregisters the given extension.- Specified by:
unregisterExtension
in interfaceExtensible
- Overrides:
unregisterExtension
in classDefaultComponent
- Parameters:
extension
- the extension to unregister
-
getContext
public RuntimeContext getContext()
-
registerSchedule
public void registerSchedule(Schedule schedule)
Description copied from interface:SchedulerService
Registers a schedule.- Specified by:
registerSchedule
in interfaceSchedulerService
- Parameters:
schedule
- the schedule
-
registerSchedule
public void registerSchedule(Schedule schedule, Map<String,Serializable> parameters)
Description copied from interface:SchedulerService
Registers a schedule. Add all parameters to eventContext.- Specified by:
registerSchedule
in interfaceSchedulerService
-
schedule
protected void schedule(Schedule schedule, Map<String,Serializable> parameters)
-
unregisterSchedule
public boolean unregisterSchedule(String id)
Description copied from interface:SchedulerService
UnRegisters a schedule.- Specified by:
unregisterSchedule
in interfaceSchedulerService
- Parameters:
id
- the schedule id- Returns:
- true if schedule has been successfully removed.
-
schedule
protected void schedule(String id, org.quartz.JobDetail job, org.quartz.Trigger trigger) throws org.quartz.SchedulerException
- Throws:
org.quartz.SchedulerException
-
unschedule
protected boolean unschedule(String id)
-
unschedule
protected boolean unschedule(String id, org.quartz.JobKey jobKey)
-
unregisterSchedule
public boolean unregisterSchedule(Schedule schedule)
Description copied from interface:SchedulerService
UnRegisters a schedule.- Specified by:
unregisterSchedule
in interfaceSchedulerService
- Parameters:
schedule
- to be unregistered- Returns:
- true if schedule has been successfully removed.
-
-