Package omero.cmd

Class HandleI

  • All Implemented Interfaces:
    java.lang.Runnable, _HandleOperations, IHandle, SessionAware, CloseableServant

    public class HandleI
    extends java.lang.Object
    implements _HandleOperations, IHandle, SessionAware
    Servant for the handle proxy from the Command API. This is also a Runnable and is passed to a ThreadPool instance
     Transitions:
    
          +------------------o [FINISHED]
          |                        o
          |                        |
     (CREATED) ---o READY o===o RUNNING o===o CANCELLING ---o [CANCELLED]
          |           |                           o                o
          |           |---------------------------|                |
          +--------------------------------------------------------+
    
     
    Since:
    4.3.2
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  HandleI.Cancel
      Signals that run() has noticed that the state diagram wants a cancellation or that the Request implementation wishes to stop execution.
    • Constructor Summary

      Constructors 
      Constructor Description
      HandleI​(int cancelTimeoutMs)
      Deprecated.
      HandleI​(ome.services.util.ReadOnlyStatus readOnly, int cancelTimeoutMs)
      Create a HandleI (at CREATED in the state diagram) with the given cancel timeout in milliseconds.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCallback​(CmdCallbackPrx cb, Ice.Current __current)
      Add a callback for notifications.
      boolean cancel​(Ice.Current __current)
      Attempts to cancel execution of this Request.
      void close​(Ice.Current current)
      Closes this handle.
      Request getRequest​(Ice.Current __current)
      Returns the request object that was used to initialize this handle.
      Response getResponse​(Ice.Current __current)
      Returns a response if this handle has finished execution, otherwise returns null.
      Status getStatus​(Ice.Current __current)
      Returns a status object for the current execution.
      void initialize​(Ice.Identity id, IRequest req, java.util.Map<java.lang.String,​java.lang.String> ctx)
      Must be called on all instances exactly once before processing.
      void notifyCallbacks()
      Calls the proper notification on all callbacks based on the current position in the state diagram.
      void removeCallback​(CmdCallbackPrx cb, Ice.Current __current)
      Remove callback for notifications.
      void run()
      NB: Executes only if at CREATED in the state diagram.
      void setSession​(SessionI session)  
      java.util.List<java.lang.Object> steps​(ome.util.SqlAction sql, org.hibernate.Session session, ome.system.ServiceFactory sf)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HandleI

        @Deprecated
        public HandleI​(int cancelTimeoutMs)
        Deprecated.
      • HandleI

        public HandleI​(ome.services.util.ReadOnlyStatus readOnly,
                       int cancelTimeoutMs)
        Create a HandleI (at CREATED in the state diagram) with the given cancel timeout in milliseconds.
        Parameters:
        readOnly - the read-only status
        cancelTimeoutMs - the cancel timeout (in milliseconds)
    • Method Detail

      • initialize

        public void initialize​(Ice.Identity id,
                               IRequest req,
                               java.util.Map<java.lang.String,​java.lang.String> ctx)
        Description copied from interface: IHandle
        Must be called on all instances exactly once before processing.
        Specified by:
        initialize in interface IHandle
        Parameters:
        id - Ice identity of this instance. Cannot be null.
        req - Request to be processed. Must also be an Request instance.
        ctx - Possibly null call context which will be passed to Executor.execute(Map, ome.system.Principal, ome.services.util.Executor.Work)
      • notifyCallbacks

        public void notifyCallbacks()
        Calls the proper notification on all callbacks based on the current position in the state diagram. If that is anything other than CANCELLED or FINISHED then CmdCallbackPrx.step(int, int) is called.
      • getRequest

        public Request getRequest​(Ice.Current __current)
        Description copied from interface: _HandleOperations
        Returns the request object that was used to initialize this handle. Never null.
        Specified by:
        getRequest in interface _HandleOperations
        Parameters:
        __current - The Current object for the invocation.
      • getResponse

        public Response getResponse​(Ice.Current __current)
        Description copied from interface: _HandleOperations
        Returns a response if this handle has finished execution, otherwise returns null.
        Specified by:
        getResponse in interface _HandleOperations
        Parameters:
        __current - The Current object for the invocation.
      • getStatus

        public Status getStatus​(Ice.Current __current)
        Description copied from interface: _HandleOperations
        Returns a status object for the current execution. This will likely be the same object that would be returned as a component of the Response value. Never null.
        Specified by:
        getStatus in interface _HandleOperations
        Parameters:
        __current - The Current object for the invocation.
      • cancel

        public boolean cancel​(Ice.Current __current)
                       throws LockTimeout
        Description copied from interface: _HandleOperations
        Attempts to cancel execution of this Request. Returns true if cancellation was successful. Returns false if not, in which case likely this request will run to completion.
        Specified by:
        cancel in interface _HandleOperations
        Parameters:
        __current - The Current object for the invocation.
        Throws:
        LockTimeout
      • close

        public void close​(Ice.Current current)
        Description copied from interface: _HandleOperations
        Closes this handle. If the request is running, then a cancellation will be attempted first. All uses of a handle should be surrounded by a try/finally close block.
        Specified by:
        close in interface _HandleOperations
        Specified by:
        close in interface CloseableServant
        Parameters:
        current - The Current object for the invocation.
      • run

        public void run()
        NB: Executes only if at CREATED in the state diagram.
        Specified by:
        run in interface java.lang.Runnable
      • steps

        public java.util.List<java.lang.Object> steps​(ome.util.SqlAction sql,
                                                      org.hibernate.Session session,
                                                      ome.system.ServiceFactory sf)
                                               throws HandleI.Cancel
        Throws:
        HandleI.Cancel