Package com.xpn.xwiki.plugin.scheduler
Class SchedulerPlugin
- java.lang.Object
-
- com.xpn.xwiki.plugin.XWikiDefaultPlugin
-
- com.xpn.xwiki.plugin.scheduler.SchedulerPlugin
-
- All Implemented Interfaces:
XWikiPluginInterface,org.xwiki.observation.EventListener
public class SchedulerPlugin extends XWikiDefaultPlugin implements org.xwiki.observation.EventListener
SeeSchedulerPluginApifor documentation.- Version:
- $Id: 11ae0ef444e6594d358b092711ac30b03d6f02b2 $
-
-
Field Summary
Fields Modifier and Type Field Description static StringXWIKI_JOB_CLASSDeprecated.useXWIKI_JOB_CLASSREFERENCEinsteadstatic org.xwiki.model.reference.EntityReferenceXWIKI_JOB_CLASSREFERENCELocal reference of the XWiki Scheduler Job Class representing a job that can be scheduled by this plugin.
-
Constructor Summary
Constructors Constructor Description SchedulerPlugin(String name, String className, XWikiContext context)Default plugin constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<org.xwiki.observation.event.Event>getEvents()JobStategetJobStatus(BaseObject object, XWikiContext context)Retrieve the job's status of a givenXWIKI_JOB_CLASSjob XObject, by asking the actual job status to the quartz scheduler instance.StringgetName()DategetNextFireTime(BaseObject object, XWikiContext context)Get the next fire time for the given job name SchedulerJobApigetPluginApi(XWikiPluginInterface plugin, XWikiContext context)DategetPreviousFireTime(BaseObject object, XWikiContext context)Give, for a BaseObject job in aJobState.STATE_NORMALstate, the previous date at which the job has been executed.org.quartz.SchedulergetScheduler()voidinit(XWikiContext context)voidonEvent(org.xwiki.observation.event.Event event, Object source, Object data)voidpauseJob(BaseObject object, XWikiContext context)Pause the job with the given name by pausing all of its current triggers.voidresumeJob(BaseObject object, XWikiContext context)Resume the job with the given name (un-pause)booleanscheduleJob(BaseObject object, XWikiContext context)voidsetScheduler(org.quartz.Scheduler scheduler)voidtriggerJob(BaseObject object, XWikiContext context)Trigger a job (execute it now)voidunscheduleJob(BaseObject object, XWikiContext context)Unschedule the given job-
Methods inherited from class com.xpn.xwiki.plugin.XWikiDefaultPlugin
beginParsing, beginRendering, commonTagsHandler, downloadAttachment, endParsing, endRendering, endRenderingHandler, flushCache, flushCache, getClassName, getLocalization, insidePREHandler, localizePlainOrKey, outsidePREHandler, setClassName, setName, startRenderingHandler, virtualInit
-
-
-
-
Field Detail
-
XWIKI_JOB_CLASS
@Deprecated public static final String XWIKI_JOB_CLASS
Deprecated.useXWIKI_JOB_CLASSREFERENCEinsteadFullname of the XWiki Scheduler Job Class representing a job that can be scheduled by this plugin.- See Also:
- Constant Field Values
-
XWIKI_JOB_CLASSREFERENCE
public static final org.xwiki.model.reference.EntityReference XWIKI_JOB_CLASSREFERENCE
Local reference of the XWiki Scheduler Job Class representing a job that can be scheduled by this plugin.
-
-
Constructor Detail
-
SchedulerPlugin
public SchedulerPlugin(String name, String className, XWikiContext context)
Default plugin constructor.
-
-
Method Detail
-
init
public void init(XWikiContext context)
- Specified by:
initin interfaceXWikiPluginInterface- Overrides:
initin classXWikiDefaultPlugin
-
getJobStatus
public JobState getJobStatus(BaseObject object, XWikiContext context) throws org.quartz.SchedulerException
Retrieve the job's status of a givenXWIKI_JOB_CLASSjob XObject, by asking the actual job status to the quartz scheduler instance. It's the actual status, as the one stored in the XObject may be changed manually by users.- Parameters:
object- the XObject to give the status of- Returns:
- the status of the Job inside the quartz scheduler, as
JobStateinstance - Throws:
org.quartz.SchedulerException
-
scheduleJob
public boolean scheduleJob(BaseObject object, XWikiContext context) throws SchedulerPluginException
- Throws:
SchedulerPluginException
-
pauseJob
public void pauseJob(BaseObject object, XWikiContext context) throws SchedulerPluginException
Pause the job with the given name by pausing all of its current triggers.- Parameters:
object- the non-wrapped XObject Job to be paused- Throws:
SchedulerPluginException
-
resumeJob
public void resumeJob(BaseObject object, XWikiContext context) throws SchedulerPluginException
Resume the job with the given name (un-pause)- Parameters:
object- the non-wrapped XObject Job to be resumed- Throws:
SchedulerPluginException
-
triggerJob
public void triggerJob(BaseObject object, XWikiContext context) throws SchedulerPluginException
Trigger a job (execute it now)- Parameters:
object- the non-wrapped XObject Job to be triggeredcontext- the XWiki context- Throws:
SchedulerPluginException
-
unscheduleJob
public void unscheduleJob(BaseObject object, XWikiContext context) throws SchedulerPluginException
Unschedule the given job- Parameters:
object- the unwrapped XObject job to be unscheduled- Throws:
SchedulerPluginException
-
getPreviousFireTime
public Date getPreviousFireTime(BaseObject object, XWikiContext context) throws SchedulerPluginException
Give, for a BaseObject job in aJobState.STATE_NORMALstate, the previous date at which the job has been executed. Note that this method does not compute a date from the CRON expression, it only returns a date value which is set each time the job is executed. If the job has never been fired this method will return null.- Parameters:
object- unwrapped XObject job for which the next fire time will be givencontext- the XWiki context- Returns:
- the next Date the job will be fired at, null if the job has never been fired
- Throws:
SchedulerPluginException
-
getNextFireTime
public Date getNextFireTime(BaseObject object, XWikiContext context) throws SchedulerPluginException
Get the next fire time for the given job name SchedulerJob- Parameters:
object- unwrapped XObject job for which the next fire time will be given- Returns:
- the next Date the job will be fired at
- Throws:
SchedulerPluginException
-
getPluginApi
public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
- Specified by:
getPluginApiin interfaceXWikiPluginInterface- Overrides:
getPluginApiin classXWikiDefaultPlugin
-
getName
public String getName()
- Specified by:
getNamein interfaceorg.xwiki.observation.EventListener- Specified by:
getNamein interfaceXWikiPluginInterface- Overrides:
getNamein classXWikiDefaultPlugin
-
setScheduler
public void setScheduler(org.quartz.Scheduler scheduler)
- Parameters:
scheduler- the scheduler to use
-
getScheduler
public org.quartz.Scheduler getScheduler()
- Returns:
- the scheduler in use
-
getEvents
public List<org.xwiki.observation.event.Event> getEvents()
- Specified by:
getEventsin interfaceorg.xwiki.observation.EventListener
-
-