|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.coderight.jazz.Task<V>
public abstract class Task<V>
Use Task for (long running) background processes.
Example: public LoadContactsTask> extends Task { public List<Contact> process() throws Exception { AddressBookService service = AddressBookService.getInstance(); return service.loadContacts(); } protected void onFinish() { ContactEvent contactEvent = new ContactEvent(ContactEventType.LOAD_SUCCESS); contactEvent.setContacts(getResult()); postEvent(contactEvent); } protected void onError() { MessageEvent error = new MessageEvent(MessageEventType.ERROR); error.setMessage(getError().getMessage()); postEvent(error); } }
Controller.executeTask(Task)| Nested Class Summary | |
|---|---|
class |
Task.FixedDelaySchedule
|
class |
Task.FixedRateSchedule
|
static class |
Task.TaskState
Enumeration of the possible Task states. |
| Constructor Summary | |
|---|---|
Task()
|
|
| Method Summary | |
|---|---|
void |
cancel()
Cancels running task. |
ProgressMonitor |
createProgressMonitor(String message,
InputStream inputStream)
Creates a ProgressMonitor. |
ProgressMonitor |
createProgressMonitor(String message,
String note,
int min,
int max)
Creates a standard ProgressMonitor. |
Exception |
getError()
Returns the error (if set). |
V |
getResult()
Returns the result from process. |
nl.coderight.jazz.Task.Schedule |
getSchedule()
Returns task schedule. |
Task.TaskState |
getState()
Returns current state. |
boolean |
hasError()
Returns true if an error is set. |
boolean |
isCanceled()
Returns true if task was canceled. |
protected void |
onCanceled()
Invoked when task is canceled. |
protected void |
onError()
Invoked when task has an error. |
protected void |
onFinish()
Invoked when task is finished. |
protected void |
onStart()
Invoked when task starts running. |
void |
postEvent(Event event)
Use to post events like ProgressEvents and message events. |
abstract V |
process()
Performs a (long running) operation. |
void |
setSchedule(nl.coderight.jazz.Task.Schedule schedule)
Sets task schedule. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Task()
| Method Detail |
|---|
public Task.TaskState getState()
Task.TaskStatepublic nl.coderight.jazz.Task.Schedule getSchedule()
public void setSchedule(nl.coderight.jazz.Task.Schedule schedule)
Task.FixedRateSchedulepublic Exception getError()
public boolean hasError()
public V getResult()
public final void cancel()
public boolean isCanceled()
public final void postEvent(Event event)
public final ProgressMonitor createProgressMonitor(String message,
String note,
int min,
int max)
ProgressMonitor
public final ProgressMonitor createProgressMonitor(String message,
InputStream inputStream)
ProgressMonitor
public abstract V process()
throws Exception
Exceptionprotected void onStart()
protected void onFinish()
protected void onError()
Default print stackstrace.
protected void onCanceled()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||