Methods Summary |
---|
public boolean | cancel()Marks this transaction as cancelled if it is running and not complete.
A transaction may be cancelled only once. After that, false is returned.
debug("cancel");
if ( ! running || completed || cancelled ) {
return false;
}
debug("canceling");
if ( ! canceling() ) {
return false;
}
debug("cancelled");
cancelled = true;
context.getTransactionManager().removeTransaction(this);
return true;
|
protected boolean | canceling()Performs subclass-specific initialization to cancel the transaction.
Return false to abort the cancellation.
return true;
|
protected void | debug(java.lang.String message)Displays a debug message tagged with the context ID.
context.debug("[" + this + "] " + message);
|
protected void | debug(java.lang.String message, java.lang.Throwable t)Displays a debug message and exception tagged with the context ID.
context.debug("[" + this + "] " + message, t);
|
protected void | executeInBrowser(java.lang.String javascript)Executes the given Javascript code in the browser.
if ( context.getTransaction(type) == this ) {
context.executeInBrowser(javascript);
}
else {
debug("Non-current transaction cannot execute: " + javascript);
}
|
public int | getId()
return id;
|
public java.lang.String | getType()
return type;
|
public boolean | isCancelled()Returns true if this transaction has been cancelled.
return cancelled;
|
public boolean | isCompleted()Returns true if this transaction has started and is still running.
return completed;
|
public boolean | isRunning()Returns true if this transaction has started and is still running.
return running;
|
protected void | sendBrowserMessage(java.lang.String key, java.lang.String op)Sends a message to the JavaScript in the page.
sendBrowserMessage(key, op, null);
|
protected void | sendBrowserMessage(java.lang.String key, java.lang.String op, java.util.Map params)Sends a message to the JavaScript in the page.
if ( context.getTransaction(type) == this ) {
context.sendBrowserMessage(key, op, params);
}
else {
debug("Non-current transaction cannot send: " + key + "." + op);
}
|
public boolean | start()Starts the transaction if it is not yet running, completed or cancelled.
A transaction may be started only once. After that, false is returned.
debug("start");
if ( running || completed || cancelled ) {
return false;
}
debug("starting");
if ( ! starting() ) {
return false;
}
debug("started");
running = true;
return true;
|
protected boolean | starting()Performs subclass-specific initialization to start the transaction.
Return false to abort the start.
return true;
|
protected boolean | stop()Marks this transaction as completed if it is running and not cancelled.
If it is running and cancelled, it is simply marked as not running.
A transaction may be stopped only once. After that, false is returned.
debug("stop");
if ( ! running ) {
return false;
}
debug("stopping");
if ( ! stopping() ) {
return false;
}
debug("stopped");
running = false;
completed = ! cancelled;
context.getTransactionManager().removeTransaction(this);
return true;
|
protected boolean | stopping()Performs subclass-specific initialization to stop the transaction.
Return false to abort the stop.
return true;
|
public java.lang.String | toString()
return type + "-" + id
+ (running ? "-running" : "")
+ (cancelled ? "-cancelled" : "")
+ (completed ? "-completed" : "");
|