Package omero.cmd

Class CmdCallbackI

    • Field Detail

      • handle

        protected final HandlePrx handle
        Proxy passed to this instance on creation. Can be used by subclasses freely. The object will not be nulled, but may be closed server-side.
    • Method Detail

      • initialPoll

        protected void initialPoll()
        Called at the end of construction to check a race condition. If HandlePrx finishes its execution before the CmdCallbackPrx has been sent set via addCallback, then there's a chance that this implementation will never receive a call to finished, leading to perceived hangs. By default, this method starts a background thread and calls poll(). An ObjectNotExistException implies that another caller has already closed the HandlePrx.
      • onFinishedDone

        protected void onFinishedDone()
      • waitOnFinishedDone

        protected void waitOnFinishedDone()
      • getResponse

        public Response getResponse()
        Returns possibly null Response value. If null, then neither has the remote server nor the local poll method called finish with non-null values.
        Returns:
        the response, may be null
      • getStatus

        public Status getStatus()
        Returns possibly null Status value. If null, then neither has the remote server nor the local poll method called finish with non-null values.
        Returns:
        the status, may be null
      • getStatusOrThrow

        protected Status getStatusOrThrow()
      • isCancelled

        public boolean isCancelled()
        Returns whether Status::CANCELLED is contained in the flags variable of the Status instance. If no Status is available, a ClientError will be thrown.
        Returns:
        if State.CANCELLED has been flagged
      • isFailure

        public boolean isFailure()
        Returns whether Status::FAILURE is contained in the flags variable of the Status instance. If no Status is available, a ClientError will be thrown.
        Returns:
        if State.FAILURE has been flagged
      • loop

        public Response loop​(int loops,
                             long ms)
                      throws java.lang.InterruptedException,
                             LockTimeout
        Calls block(long) "loops" number of times with the "ms" argument. This means the total wait time for the action to occur is: loops X ms. Sensible values might be 10 loops for 500 ms, or 5 seconds.
        Parameters:
        loops - Number of times to call block(long)
        ms - Number of milliseconds to pass to block(long
        Returns:
        the response
        Throws:
        java.lang.InterruptedException - if the thread was interrupted
        LockTimeout - if block(long) does not return a non-null value after loops calls.
      • block

        public boolean block​(long ms)
                      throws java.lang.InterruptedException
        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.
        Parameters:
        ms - Milliseconds which this method should block for.
        Returns:
        if the the thread finished before the timeout was reached
        Throws:
        java.lang.InterruptedException - if the thread was interrupted
      • step

        public void step​(int complete,
                         int total,
                         Ice.Current __current)
        Called periodically by the server to signal that processing is moving forward. Default implementation does nothing.
        __current - The Current object for the invocation.
      • finished

        public final void finished​(Response rsp,
                                   Status status,
                                   Ice.Current __current)
        Called when the command has completed.
        __current - The Current object for the invocation.
      • onFinished

        public void onFinished​(Response rsp,
                               Status status,
                               Ice.Current __current)
        Method intended to be overridden by subclasses. Default logic does nothing.
        Parameters:
        rsp - the response
        status - the status
        __current - regarding the current method invocation
      • close

        public void close​(boolean closeHandle)
        First removes self from the adapter so as to no longer receive notifications, and the calls close on the remote handle if requested.
        Parameters:
        closeHandle - if the handle should be closed