public class SchedulerPluginApi extends PluginApi<SchedulerPlugin>
Jobs are represented by Object
XObjects, instances of the
SchedulerPlugin.XWIKI_JOB_CLASS
XClass. These XObjects do store a job name, the implementation class name of
the job to be executed, the cron expression to precise when the job should be fired, and possibly a groovy script
with the job's program.
The plugin offers a GroovyJob
Groovy Job wrapper to execute groovy scripts
(typically for use inside the Wiki), but can also be used with any Java class implementing Job
Constructor and Description |
---|
SchedulerPluginApi(SchedulerPlugin plugin,
XWikiContext context) |
Modifier and Type | Method and Description |
---|---|
JobState |
getJobStatus(BaseObject object)
Return the trigger state as a $
JobState , that holds both the integer trigger's inner value of the state
and a String as a human readable representation of that state |
JobState |
getJobStatus(Object object) |
Date |
getNextFireTime(BaseObject object) |
Date |
getNextFireTime(Object object)
Give, for a XObject job in a
JobState.STATE_NORMAL state, the next date at which the job will be
executed, according to its cron expression. |
Date |
getPreviousFireTime(BaseObject object)
Give, for a BaseObject job in a
JobState.STATE_NORMAL state, the previous date at which the job has been
executed. |
Date |
getPreviousFireTime(Object object)
Give, for a XObject job in a
JobState.STATE_NORMAL state, the previous date at which the job has been
executed, the fire time is not computed from the CRON expression, this method will return null if the . |
String |
getStatus(Object object)
Return the trigger state of the given
SchedulerPlugin.XWIKI_JOB_CLASS
XObject job. |
boolean |
pauseJob(BaseObject object) |
boolean |
pauseJob(Object object)
Pause the given XObject job by pausing all of its current triggers.
|
boolean |
resumeJob(BaseObject object) |
boolean |
resumeJob(Object object)
Resume a XObject job that is in a
JobState.STATE_PAUSED state. |
boolean |
scheduleJob(BaseObject object) |
boolean |
scheduleJob(Object object)
Schedule the given XObject to be executed according to its parameters.
|
boolean |
scheduleJobs(Document document)
Schedule all
SchedulerPlugin.XWIKI_JOB_CLASS XObjects stored inside the
given Wiki document, according to each XObject own parameters. |
boolean |
triggerJob(BaseObject object)
Trigger a BaseObject job (execute it now).
|
boolean |
triggerJob(Object object)
Trigger a XObject job (execute it now).
|
boolean |
unscheduleJob(BaseObject object) |
boolean |
unscheduleJob(Object object)
Unschedule a XObject job by deleting it from the jobs table.
|
getInternalPlugin, getProtectedPlugin, setPlugin
convert, convert, convert, convertAttachments, getAuthorizationManager, getContextualAuthorizationManager, getXWikiContext, hasAccess, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
public SchedulerPluginApi(SchedulerPlugin plugin, XWikiContext context)
public String getStatus(Object object)
SchedulerPlugin.XWIKI_JOB_CLASS
XObject job. Possible values are : None (the trigger does not exists yet, or has been deleted), Normal, Blocked,
Complete, Error and Pausedobject
- the XObject job to give the state ofpublic JobState getJobStatus(BaseObject object) throws org.quartz.SchedulerException
JobState
, that holds both the integer trigger's inner value of the state
and a String as a human readable representation of that stateorg.quartz.SchedulerException
public JobState getJobStatus(Object object) throws org.quartz.SchedulerException, SchedulerPluginException
org.quartz.SchedulerException
SchedulerPluginException
public boolean scheduleJob(Object object)
#if($xwiki.scheduler.scheduleJob($job)!=true)
#error($xcontext.get("error") #else #info("Job scheduled") #end
Where $job is an XObject, instance of the SchedulerPlugin.XWIKI_JOB_CLASS
XClassobject
- the XObject to be scheduled, an instance of the XClass XWiki.SchedulerJobClasspublic boolean scheduleJob(BaseObject object)
public boolean scheduleJobs(Document document)
SchedulerPlugin.XWIKI_JOB_CLASS
XObjects stored inside the
given Wiki document, according to each XObject own parameters.document
- the document holding the XObjects Jobs to be scheduledpublic boolean pauseJob(Object object)
scheduleJob(Object)
object
- the wrapped XObject Job to be pausedpublic boolean pauseJob(BaseObject object)
public boolean resumeJob(Object object)
JobState.STATE_PAUSED
state. Can be called the same way as
scheduleJob(Object)
object
- the wrapped XObject Job to be pausedpublic boolean resumeJob(BaseObject object)
public boolean unscheduleJob(Object object)
scheduleJob(Object)
object
- the wrapped XObject Job to be pausedpublic boolean unscheduleJob(BaseObject object)
public boolean triggerJob(Object object)
object
- the wrapped XObject Job to be triggeredpublic boolean triggerJob(BaseObject object)
object
- the BaseObject Job to be triggeredpublic Date getPreviousFireTime(Object object)
JobState.STATE_NORMAL
state, the previous date at which the job has been
executed, the fire time is not computed from the CRON expression, this method will return null if the .object
- the wrapped XObject for which to give the fire timepublic Date getPreviousFireTime(BaseObject object)
JobState.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.object
- the BaseObject for which to give the fire timepublic Date getNextFireTime(Object object)
JobState.STATE_NORMAL
state, the next date at which the job will be
executed, according to its cron expression. Errors are returned in the context map. Can be called for example:
#set($firetime = $xwiki.scheduler.getNextFireTime($job))
#if (!$firetime || $firetime=="") #error($xcontext.get("error") #else #info("Fire time :
$firetime") #end
Where $job is an XObject, instance of the SchedulerPlugin.XWIKI_JOB_CLASS
XClassobject
- the wrapped XObject for which to give the fire datepublic Date getNextFireTime(BaseObject object)
Copyright © 2004–2021 XWiki. All rights reserved.