Package org.appng.api
Interface ScheduledJob
-
public interface ScheduledJob
AScheduledJob
is a (periodically or manually triggered) task that can be defined by anApplication
. The job'sjobDataMap
can contain any information that the job needs to be executed. For periodical execution, there are two pre-defined entries for thejobDataMap
:cronExpression
A cron-expression describing when theScheduledJob
should be executed.enabled
If set totrue
and thecronExpression
property is present (and valid), theScheduledJob
will automatically be scheduled when the platform starts.runOnce
If set totrue
, this job will only run once per cluster, i.e. it is not executed on each node, which is the default behavior.hardInterruptable
If set totrue
, this job can safely be interrupted, e.g when aSite
is being reloaded. This is achieved by running the job in a separate thread and callingThread.interrupt()
.allowConcurrentExecutions
If set totrue
, multiple instances of this job can run concurrently (default isfalse
).
- Author:
- Matthias Müller
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
execute(Site site, Application application)
This method actually executes the job.String
getDescription()
Returns the description for this job.Map<String,Object>
getJobDataMap()
Returns aMap
containing some data needed the execute the jobdefault ScheduledJobResult
getResult()
This method is called after execution of the job.void
setDescription(String description)
Sets the description for this job.void
setJobDataMap(Map<String,Object> map)
Sets thejobDataMap
for this job.
-
-
-
Method Detail
-
getDescription
String getDescription()
Returns the description for this job.- Returns:
- the description
-
setDescription
void setDescription(String description)
Sets the description for this job.- Parameters:
description
- the description
-
getJobDataMap
Map<String,Object> getJobDataMap()
Returns aMap
containing some data needed the execute the job- Returns:
- the
jobDataMap
-
setJobDataMap
void setJobDataMap(Map<String,Object> map)
Sets thejobDataMap
for this job.- Parameters:
map
-jobDataMap
-
execute
void execute(Site site, Application application) throws Exception
This method actually executes the job.- Parameters:
site
- theSite
to run withinapplication
- theApplication
to run within- Throws:
Exception
- if any error occurs during job execution
-
getResult
default ScheduledJobResult getResult()
This method is called after execution of the job. It has to provide the result and optionally some custom information to be stored in the appNG database.- Returns:
- the
ScheduledJobResult
-
-