public abstract class Task extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
protected ContextProperties |
config |
protected boolean |
interruptRequested |
protected Throwable |
lastRunError |
protected LockManager |
lockManager |
protected org.slf4j.Logger |
log |
protected boolean |
sendActivityReport |
protected EMailSender |
sender |
protected long |
size |
static int |
STATUS_IDLE |
static int |
STATUS_RUNNING |
static int |
STATUS_STOPPING |
protected SystemLoadMonitor |
systemLoadMonitor |
protected String |
transactionId |
protected UserDAO |
userDao |
Modifier and Type | Method and Description |
---|---|
void |
addTaskListener(TaskListener listener) |
int |
getCompletionPercentage()
The percentage of completion(1-100)
|
ContextProperties |
getConfig() |
String |
getName() |
long |
getProgress()
The current processing step
|
String |
getReportRecipients() |
TaskScheduling |
getScheduling()
Scheduling policies
|
long |
getSize()
The the total size of the processing(number of units of work)
|
int |
getStatus()
The task status(one of STATUS_IDLE or STATUS_RUNNING)
|
void |
interrupt() |
abstract boolean |
isConcurrent()
Concrete implementations must override this method declaring if the task
supports multiple instances running concurrently.
|
abstract boolean |
isIndeterminate()
Concrete implementations must override this method declaring if the task
is indeterminate.
|
boolean |
isInterrupted() |
boolean |
isRunning()
Check if the task is currently running
|
boolean |
isSendActivityReport() |
protected void |
next()
Increments the progress by one and detects system overload.
|
void |
notifyReport() |
protected String |
prepareReport(Locale locale)
Implementations may compose a locale specific report.
|
void |
removeTaskListener(TaskListener listener) |
void |
run() |
protected abstract void |
runTask()
Concrete implementations must override this method implementing their own
processing logic.
|
void |
save()
Saves the task configuration
|
void |
saveWork()
Concrete implementations must insert here the code needed to save the
elaboration state in a persistent storage
|
void |
setConfig(ContextProperties config) |
void |
setLockManager(LockManager lockManager) |
protected void |
setName(String name) |
protected void |
setProgress(long progress) |
void |
setReportRecipients(String reportRecipients) |
void |
setSendActivityReport(boolean sendActivityReport) |
void |
setSender(EMailSender sender) |
void |
setSize(long size) |
void |
setSystemLoadMonitor(SystemLoadMonitor systemLoadMonitor) |
void |
setUserDao(UserDAO userDao) |
protected org.slf4j.Logger log
public static final int STATUS_IDLE
public static final int STATUS_RUNNING
public static final int STATUS_STOPPING
protected long size
protected boolean interruptRequested
protected Throwable lastRunError
protected ContextProperties config
protected EMailSender sender
protected UserDAO userDao
protected boolean sendActivityReport
protected String transactionId
protected LockManager lockManager
protected SystemLoadMonitor systemLoadMonitor
public Task(String name)
public String getName()
protected void setName(String name)
protected void next()
protected void setProgress(long progress)
public void interrupt()
public boolean isInterrupted()
public long getSize()
public void setSize(long size)
public int getStatus()
public long getProgress()
public int getCompletionPercentage()
public boolean isRunning()
public void saveWork()
public TaskScheduling getScheduling()
public void addTaskListener(TaskListener listener)
public void removeTaskListener(TaskListener listener)
public void notifyReport()
protected String prepareReport(Locale locale)
protected abstract void runTask() throws Exception
Exception
- If something goes wrong this exception is raisedpublic abstract boolean isIndeterminate()
public abstract boolean isConcurrent()
public String getReportRecipients()
public ContextProperties getConfig()
public void setConfig(ContextProperties config)
public void setSender(EMailSender sender)
public void setUserDao(UserDAO userDao)
public void save() throws IOException, ParseException
ParseException
IOException
public boolean isSendActivityReport()
public void setSendActivityReport(boolean sendActivityReport)
public void setReportRecipients(String reportRecipients)
public void setLockManager(LockManager lockManager)
public void setSystemLoadMonitor(SystemLoadMonitor systemLoadMonitor)
Copyright © 2008-2014 Logical Objects. All Rights Reserved.