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
SeeSchedulerPluginApi
for documentation.- Version:
- $Id: 11ae0ef444e6594d358b092711ac30b03d6f02b2 $
-
-
Field Summary
Fields Modifier and Type Field Description static String
XWIKI_JOB_CLASS
Deprecated.useXWIKI_JOB_CLASSREFERENCE
insteadstatic 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 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()
JobState
getJobStatus(BaseObject object, XWikiContext context)
Retrieve the job's status of a givenXWIKI_JOB_CLASS
job XObject, by asking the actual job status to the quartz scheduler instance.String
getName()
Date
getNextFireTime(BaseObject object, XWikiContext context)
Get the next fire time for the given job name SchedulerJobApi
getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
Date
getPreviousFireTime(BaseObject object, XWikiContext context)
Give, for a BaseObject job in aJobState.STATE_NORMAL
state, the previous date at which the job has been executed.org.quartz.Scheduler
getScheduler()
void
init(XWikiContext context)
void
onEvent(org.xwiki.observation.event.Event event, Object source, Object data)
void
pauseJob(BaseObject object, XWikiContext context)
Pause the job with the given name by pausing all of its current triggers.void
resumeJob(BaseObject object, XWikiContext context)
Resume the job with the given name (un-pause)boolean
scheduleJob(BaseObject object, XWikiContext context)
void
setScheduler(org.quartz.Scheduler scheduler)
void
triggerJob(BaseObject object, XWikiContext context)
Trigger a job (execute it now)void
unscheduleJob(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_CLASSREFERENCE
insteadFullname 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:
init
in interfaceXWikiPluginInterface
- Overrides:
init
in classXWikiDefaultPlugin
-
getJobStatus
public JobState getJobStatus(BaseObject object, XWikiContext context) throws org.quartz.SchedulerException
Retrieve the job's status of a givenXWIKI_JOB_CLASS
job 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
JobState
instance - 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_NORMAL
state, 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:
getPluginApi
in interfaceXWikiPluginInterface
- Overrides:
getPluginApi
in classXWikiDefaultPlugin
-
getName
public String getName()
- Specified by:
getName
in interfaceorg.xwiki.observation.EventListener
- Specified by:
getName
in interfaceXWikiPluginInterface
- Overrides:
getName
in 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:
getEvents
in interfaceorg.xwiki.observation.EventListener
-
-