Saros
Distributed Collaborative Editing and Distributed Party Programming
de.fu_berlin.inf.dpp.negotiation.CancelableProcess Class Reference
Inheritance diagram for de.fu_berlin.inf.dpp.negotiation.CancelableProcess:
de.fu_berlin.inf.dpp.negotiation.ProjectNegotiation de.fu_berlin.inf.dpp.negotiation.SessionNegotiation de.fu_berlin.inf.dpp.core.invitation.IncomingProjectNegotiation de.fu_berlin.inf.dpp.core.invitation.OutgoingProjectNegotiation de.fu_berlin.inf.dpp.negotiation.IncomingProjectNegotiation de.fu_berlin.inf.dpp.negotiation.OutgoingProjectNegotiation de.fu_berlin.inf.dpp.negotiation.IncomingSessionNegotiation de.fu_berlin.inf.dpp.negotiation.OutgoingSessionNegotiation

List of all members.

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)

Detailed Description

Abstract base class that offers multiple methods for handling cancellation.

Author:
srossbach

Member Enumeration Documentation

Enumerator:
OK 
CANCEL 
REMOTE_CANCEL 
ERROR 
REMOTE_ERROR 

Member Function Documentation

final void de.fu_berlin.inf.dpp.negotiation.CancelableProcess.addCancelListener ( final CancelListener  listener)

Adds the given listener for cancellation events to this negotiation.

Parameters:
listenerthe 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.

Parameters:
cancelOptionthe cancel option to use when a local cancellation was set
Exceptions:
SarosCancellationExceptionif 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.

Returns:
the error message
final synchronized boolean de.fu_berlin.inf.dpp.negotiation.CancelableProcess.isCanceled ( )

Returns if this process should be canceled.

Returns:
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

Returns:
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

Returns:
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.

Parameters:
errorMessagethe reason to cancel the execution in case of an error or null if this is a normal cancel request
cancelOptioneither CancelOption#NOTIFY_PEER to inform the remote side of the cancellation or CancelOption#DO_NOT_NOTIFY_PEER
Returns:
true if this request was the first cancel request, false otherwise
See also:
remoteCancel
checkCancellation
notifyCancellation

Reimplemented 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.

Parameters:
cancellationCausethe 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

Parameters:
listenerto 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.

Parameters:
monitorthe monitor to observer
See also:
#isLocalCancellation
checkCancellation(CancelOption)
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.

Parameters:
errorMessagethe reason to cancel the execution in case of an error or null if this is a cancel abort request
Returns:
true if this request was the first cancel request, false otherwise
See also:
localCancel
checkCancellation
notifyCancellation

Reimplemented 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.

Parameters:
listenerthe 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.

Parameters:
listenerthe 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.

Parameters:
exceptionThe 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.
Returns:
the Status of the termination
 All Classes Namespaces Files Functions Variables Enumerations