Saros
Distributed Collaborative Editing and Distributed Party Programming
|
Public Types | |
enum | Status { OK, CANCEL, REMOTE_CANCEL, ERROR, REMOTE_ERROR } |
Public Member Functions | |
final void | setNegotiationListener (final NegotiationListener listener) |
synchronized String | getErrorMessage () |
boolean | localCancel (String errorMessage, CancelOption cancelOption) |
boolean | remoteCancel (String errorMessage) |
final void | addCancelListener (final CancelListener listener) |
final void | removeCancelListener (final CancelListener listener) |
final synchronized boolean | isCanceled () |
final synchronized boolean | isLocalCancellation () |
final synchronized boolean | isRemoteCancellation () |
Protected Member Functions | |
abstract void | executeCancellation () |
abstract void | notifyCancellation (SarosCancellationException cancellationCause) |
synchronized final void | observeMonitor (IProgressMonitor monitor) |
synchronized final void | checkCancellation (CancelOption cancelOption) throws SarosCancellationException |
final Status | terminateProcess (Exception exception) |
abstract void | notifyTerminated (NegotiationListener listener) |
Abstract base class that offers multiple methods for handling cancellation.
final void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.addCancelListener | ( | final CancelListener | listener | ) |
Adds the given listener for cancellation events to this negotiation.
listener | the listener to add |
synchronized final void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.checkCancellation | ( | CancelOption | cancelOption | ) | throws SarosCancellationException [protected] |
Checks the current cancellation status of this process. If a local cancellation request is detected this method will invoke localCancel(String errorMessage, CancelOption cancelOption) with null
as errorMessage argument.
cancelOption | the cancel option to use when a local cancellation was set |
SarosCancellationException | if the current process should be canceled |
abstract void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.executeCancellation | ( | ) | [protected, pure virtual] |
This method is called after terminateProcess decides to perform a cleanup because the execution of the process was canceled. Implementing classes should try a maximum effort to revert all the changes that were made before the process was aborted.
Implemented in de.fu_berlin.inf.dpp.negotiation.IncomingSessionNegotiation, de.fu_berlin.inf.dpp.negotiation.OutgoingSessionNegotiation, de.fu_berlin.inf.dpp.negotiation.IncomingProjectNegotiation, de.fu_berlin.inf.dpp.negotiation.OutgoingProjectNegotiation, de.fu_berlin.inf.dpp.core.invitation.IncomingProjectNegotiation, and de.fu_berlin.inf.dpp.core.invitation.OutgoingProjectNegotiation.
synchronized String de.fu_berlin.inf.dpp.negotiation.CancelableProcess.getErrorMessage | ( | ) |
Returns the error message if the exit status of the process was either Status#ERROR or Status#REMOTE_ERROR.
final synchronized boolean de.fu_berlin.inf.dpp.negotiation.CancelableProcess.isCanceled | ( | ) |
Returns if this process should be canceled.
true
this process should be canceled, false
otherwise final synchronized boolean de.fu_berlin.inf.dpp.negotiation.CancelableProcess.isLocalCancellation | ( | ) |
Returns if the current process should be canceled because of a local cancellation request
true
if cancellation is requested on the local side, false
otherwise final synchronized boolean de.fu_berlin.inf.dpp.negotiation.CancelableProcess.isRemoteCancellation | ( | ) |
Returns if the current process should be canceled because of a remote cancellation request
true
if cancellation is requested on the remote side, false
otherwise boolean de.fu_berlin.inf.dpp.negotiation.CancelableProcess.localCancel | ( | String | errorMessage, |
CancelOption | cancelOption | ||
) |
Informs the current process that it should cancel its operation as soon as possible. Calling this method multiple times will NOT override the error message or the cancel option. This method will also have NO effect if a remote cancellation request was already executed.
errorMessage | the reason to cancel the execution in case of an error or null if this is a normal cancel request |
cancelOption | either CancelOption#NOTIFY_PEER to inform the remote side of the cancellation or CancelOption#DO_NOT_NOTIFY_PEER |
true
if this request was the first cancel request, false
otherwiseReimplemented in de.fu_berlin.inf.dpp.negotiation.IncomingSessionNegotiation, de.fu_berlin.inf.dpp.negotiation.IncomingProjectNegotiation, and de.fu_berlin.inf.dpp.core.invitation.IncomingProjectNegotiation.
abstract void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.notifyCancellation | ( | SarosCancellationException | cancellationCause | ) | [protected, pure virtual] |
This method is called after terminateProcess decides to cancel the current process. It is up to the implementing class to forward this notification.
cancellationCause | the cause of the cancellation |
Implemented in de.fu_berlin.inf.dpp.negotiation.ProjectNegotiation, and de.fu_berlin.inf.dpp.negotiation.SessionNegotiation.
abstract void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.notifyTerminated | ( | NegotiationListener | listener | ) | [protected, pure virtual] |
Informs the listener, that the process is terminated. Otherwise, the SessionManager would block the execution and wait until the process is terminated
listener | to notify |
Implemented in de.fu_berlin.inf.dpp.negotiation.ProjectNegotiation, and de.fu_berlin.inf.dpp.negotiation.SessionNegotiation.
synchronized final void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.observeMonitor | ( | IProgressMonitor | monitor | ) | [protected] |
Registers a monitor which should be observed to determine the status of a local cancellation of the current process.
monitor | the monitor to observer |
boolean de.fu_berlin.inf.dpp.negotiation.CancelableProcess.remoteCancel | ( | String | errorMessage | ) |
Informs the current process that it should cancel its operation as soon as possible. Calling this method multiple times will NOT override the error message. This method will also have NO effect if a local cancellation request was already executed.
errorMessage | the reason to cancel the execution in case of an error or null if this is a cancel abort request |
true
if this request was the first cancel request, false
otherwiseReimplemented in de.fu_berlin.inf.dpp.negotiation.IncomingSessionNegotiation, de.fu_berlin.inf.dpp.negotiation.IncomingProjectNegotiation, and de.fu_berlin.inf.dpp.core.invitation.IncomingProjectNegotiation.
final void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.removeCancelListener | ( | final CancelListener | listener | ) |
Removes the given listener for cancellation events from this negotiation.
listener | the listener to remove |
final void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.setNegotiationListener | ( | final NegotiationListener | listener | ) |
Sets a NegotiationListener process listener} for the current negotiation.
listener | the listener that should be notified |
final Status de.fu_berlin.inf.dpp.negotiation.CancelableProcess.terminateProcess | ( | Exception | exception | ) | [protected] |
Terminates the current process. This method may be called multiple times but only the first call will be taken into account. If the process was canceled in the meantime it will invoke notifyCancellation and executeCancellation in this order.
exception | The exception to analyze or null . If the process had already been canceled by a localCancel or a remoteCancel call the exception will be ignored. If the exception is null then the exit status will be determined on former localCancel or remoteCancel calls. |