com.xpn.xwiki.plugin.scheduler
Class SchedulerPluginApi

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.plugin.PluginApi<SchedulerPlugin>
          extended by com.xpn.xwiki.plugin.scheduler.SchedulerPluginApi

public class SchedulerPluginApi
extends com.xpn.xwiki.plugin.PluginApi<SchedulerPlugin>

A Scheduler plugin to plan execution of Jobs from XWiki with cron expressions. The plugin uses Quartz's scheduling library.

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

Version:
$Id: SchedulerPluginApi.java 10263 2008-06-11 22:45:52Z sdumitriu $

Field Summary
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
SchedulerPluginApi(SchedulerPlugin plugin, com.xpn.xwiki.XWikiContext context)
           
 
Method Summary
 JobState getJobStatus(com.xpn.xwiki.objects.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(com.xpn.xwiki.api.Object object)
           
 java.util.Date getNextFireTime(com.xpn.xwiki.objects.BaseObject object)
           
 java.util.Date getNextFireTime(com.xpn.xwiki.api.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.
 java.lang.String getStatus(com.xpn.xwiki.api.Object object)
          Return the trigger state of the given SchedulerPlugin.XWIKI_JOB_CLASS XObject job.
 boolean pauseJob(com.xpn.xwiki.objects.BaseObject object)
           
 boolean pauseJob(com.xpn.xwiki.api.Object object)
          Pause the given XObject job by pausing all of its current triggers.
 boolean resumeJob(com.xpn.xwiki.objects.BaseObject object)
           
 boolean resumeJob(com.xpn.xwiki.api.Object object)
          Resume a XObject job that is in a JobState.STATE_PAUSED state.
 boolean scheduleJob(com.xpn.xwiki.objects.BaseObject object)
           
 boolean scheduleJob(com.xpn.xwiki.api.Object object)
          Schedule the given XObject to be executed according to its parameters.
 boolean scheduleJobs(com.xpn.xwiki.api.Document document)
          Schedule all SchedulerPlugin.XWIKI_JOB_CLASS XObjects stored inside the given Wiki document, according to each XObject own parameters.
 boolean unscheduleJob(com.xpn.xwiki.objects.BaseObject object)
           
 boolean unscheduleJob(com.xpn.xwiki.api.Object object)
          Unschedule a XObject job by deleting it from the jobs table.
 
Methods inherited from class com.xpn.xwiki.plugin.PluginApi
getInternalPlugin, getPlugin, getProtectedPlugin, setPlugin
 
Methods inherited from class com.xpn.xwiki.api.Api
checkProgrammingRights, convert, convert, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchedulerPluginApi

public SchedulerPluginApi(SchedulerPlugin plugin,
                          com.xpn.xwiki.XWikiContext context)
Method Detail

getStatus

public java.lang.String getStatus(com.xpn.xwiki.api.Object object)
Return the trigger state of the given 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 Paused

Parameters:
object - the XObject job to give the state of
Returns:
a String representing this state

getJobStatus

public JobState getJobStatus(com.xpn.xwiki.objects.BaseObject object)
                      throws org.quartz.SchedulerException,
                             SchedulerPluginException
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

Throws:
org.quartz.SchedulerException
SchedulerPluginException

getJobStatus

public JobState getJobStatus(com.xpn.xwiki.api.Object object)
                      throws org.quartz.SchedulerException,
                             SchedulerPluginException
Throws:
org.quartz.SchedulerException
SchedulerPluginException

scheduleJob

public boolean scheduleJob(com.xpn.xwiki.api.Object object)
Schedule the given XObject to be executed according to its parameters. Errors are returned in the context map. Scheduling can be called for example: #if($xwiki.scheduler.scheduleJob($job)!=true) #error($context.get("error") #else #info("Job scheduled") #end Where $job is an XObject, instance of the SchedulerPlugin.XWIKI_JOB_CLASS XClass

Parameters:
object - the XObject to be scheduled, an instance of the XClass XWiki.SchedulerJobClass
Returns:
true on success, false on failure

scheduleJob

public boolean scheduleJob(com.xpn.xwiki.objects.BaseObject object)

scheduleJobs

public boolean scheduleJobs(com.xpn.xwiki.api.Document document)
Schedule all SchedulerPlugin.XWIKI_JOB_CLASS XObjects stored inside the given Wiki document, according to each XObject own parameters.

Parameters:
document - the document holding the XObjects Jobs to be scheduled
Returns:
true on success, false on failure.

pauseJob

public boolean pauseJob(com.xpn.xwiki.api.Object object)
Pause the given XObject job by pausing all of its current triggers. Can be called the same way as scheduleJob(Object)

Parameters:
object - the wrapped XObject Job to be paused
Returns:
true on success, false on failure.

pauseJob

public boolean pauseJob(com.xpn.xwiki.objects.BaseObject object)

resumeJob

public boolean resumeJob(com.xpn.xwiki.api.Object object)
Resume a XObject job that is in a JobState.STATE_PAUSED state. Can be called the same way as scheduleJob(Object)

Parameters:
object - the wrapped XObject Job to be paused
Returns:
true on success, false on failure.

resumeJob

public boolean resumeJob(com.xpn.xwiki.objects.BaseObject object)

unscheduleJob

public boolean unscheduleJob(com.xpn.xwiki.api.Object object)
Unschedule a XObject job by deleting it from the jobs table. Can be called the same way as scheduleJob(Object)

Parameters:
object - the wrapped XObject Job to be paused
Returns:
true on success, false on failure.

unscheduleJob

public boolean unscheduleJob(com.xpn.xwiki.objects.BaseObject object)

getNextFireTime

public java.util.Date getNextFireTime(com.xpn.xwiki.api.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. Errors are returned in the context map. Can be called for example: #set($firetime = $xwiki.scheduler.getNextFireTime($job)) #if (!$firetime || $firetime=="") #error($context.get("error") #else #info("Fire time : $firetime") #end Where $job is an XObject, instance of the SchedulerPlugin.XWIKI_JOB_CLASS XClass

Parameters:
object - the wrapped XObject for which to give the fire date
Returns:
the date the job will be executed

getNextFireTime

public java.util.Date getNextFireTime(com.xpn.xwiki.objects.BaseObject object)


Copyright © 2004-2009 XWiki. All Rights Reserved.