Package omero.cmd
Class HandleI
- java.lang.Object
-
- omero.cmd.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 aRunnable
and is passed to a ThreadPool instanceTransitions: +------------------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
-
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 thisRequest
.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 atCREATED
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)
-
-
-
Constructor Detail
-
HandleI
@Deprecated public HandleI(int cancelTimeoutMs)
Deprecated.
-
HandleI
public HandleI(ome.services.util.ReadOnlyStatus readOnly, int cancelTimeoutMs)
Create aHandleI
(atCREATED
in the state diagram) with the given cancel timeout in milliseconds.- Parameters:
readOnly
- the read-only statuscancelTimeoutMs
- the cancel timeout (in milliseconds)
-
-
Method Detail
-
setSession
public void setSession(SessionI session) throws ServerError
- Specified by:
setSession
in interfaceSessionAware
- Throws:
ServerError
-
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 interfaceIHandle
- Parameters:
id
- Ice identity of this instance. Cannot be null.req
- Request to be processed. Must also be anRequest
instance.ctx
- Possibly null call context which will be passed toExecutor.execute(Map, ome.system.Principal, ome.services.util.Executor.Work)
-
addCallback
public void addCallback(CmdCallbackPrx cb, Ice.Current __current)
Description copied from interface:_HandleOperations
Add a callback for notifications.- Specified by:
addCallback
in interface_HandleOperations
__current
- The Current object for the invocation.
-
removeCallback
public void removeCallback(CmdCallbackPrx cb, Ice.Current __current)
Description copied from interface:_HandleOperations
Remove callback for notifications.- Specified by:
removeCallback
in interface_HandleOperations
__current
- The Current object for the invocation.
-
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 thanCANCELLED
orFINISHED
thenCmdCallbackPrx.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 theResponse
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 thisRequest
. 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 interfaceCloseableServant
- Parameters:
current
- The Current object for the invocation.
-
run
public void run()
NB: Executes only if atCREATED
in the state diagram.- Specified by:
run
in interfacejava.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
-
-