Package omero :: Module callbacks :: Class CmdCallbackI
[hide private]
[frames] | no frames]

Class CmdCallbackI

source code



Callback servant used to wait until a HandlePrx would
return non-null on getReponse. The server will notify
of completion to prevent constantly polling on
getResponse. Subclasses can override methods for handling
based on the completion status.

Example usage:

    cb = CmdCallbackI(client, handle)
    response = None
    while (response is None):
        response = cb.block(500)

    # or

    response = cb.loop(5, 500)

Instance Methods [hide private]
 
__init__(self, adapter_or_client, handle, category=None) source code
 
getResponse(self)
Returns possibly null Response value.
source code
 
getStatus(self)
Returns possibly null Status value.
source code
 
getStatusOrThrow(self) source code
 
isCancelled(self)
Returns whether Status::CANCELLED is contained in the flags variable of the Status instance.
source code
 
isFailure(self)
Returns whether Status::FAILURE is contained in the flags variable of the Status instance.
source code
 
loop(self, loops, ms)
Calls block(long) "loops" number of times with the "ms" argument.
source code
 
block(self, ms)
Blocks for the given number of milliseconds unless finished(Response, Status, Current) has been called in which case it returns immediately with true.
source code
 
poll(self)
Calls HandlePrx#getResponse in order to check for a non-null value.
source code
 
step(self, complete, total, current=None)
Called periodically by the server to signal that processing is moving forward.
source code
 
finished(self, rsp, status, current=None)
Called when the command has completed whether with a cancellation or a completion.
source code
 
onFinished(self, rsp, status, current)
Method intended to be overridden by subclasses.
source code
 
close(self, closeHandle)
First removes self from the adapter so as to no longer receive notifications, and the calls close on the remote handle if requested.
source code
Method Details [hide private]

getResponse(self)

source code 

Returns possibly null Response value. If null, then neither has the remote server nor the local poll method called finish with non-null values.

getStatus(self)

source code 

Returns possibly null Status value. If null, then neither has the remote server nor the local poll method called finish with non-null values.

isCancelled(self)

source code 

Returns whether Status::CANCELLED is contained in the flags variable of the Status instance. If no Status is available, a ClientError will be thrown.

isFailure(self)

source code 

Returns whether Status::FAILURE is contained in the flags variable of the Status instance. If no Status is available, a ClientError will be thrown.

loop(self, loops, ms)

source code 

Calls block(long) "loops" number of times with the "ms" argument. This means the total wait time for the delete to occur is: loops X ms. Sensible values might be 10 loops for 500 ms, or 5 seconds.

@param loops Number of times to call block(long) @param ms Number of milliseconds to pass to block(long @throws omero.LockTimeout if block(long) does not return a non-null value after loops calls.

block(self, ms)

source code 

Blocks for the given number of milliseconds unless finished(Response, Status, Current) has been called in which case it returns immediately with true. If false is returned, then the timeout was reached.

poll(self)

source code 

Calls HandlePrx#getResponse in order to check for a non-null value. If so, {@link Handle#getStatus} is also called, and the two non-null values are passed to finished(Response, Status, Current). This should typically not be used. Instead, favor the use of block and loop.

step(self, complete, total, current=None)

source code 

Called periodically by the server to signal that processing is moving forward. Default implementation does nothing.

onFinished(self, rsp, status, current)

source code 

Method intended to be overridden by subclasses. Default logic does nothing.