Interface OperationHandle<T extends Annotation>
- All Known Implementing Classes:
OperationHandleImpl
This handle is used to associate or dis-associate threads with
Operations. It can also be used to close this Operation.
Every OperationHandle will be added as an HK2 service in
the Operations scope, and hence can be injected into other
HK2 services
-
Method Summary
Modifier and TypeMethodDescriptionvoid
suspends this Operation on all threads where it is associated and closes the operation.Gets a set of threads upon which this Operation is activeReturns a unique identifier for this operationGets arbitrary Operation data to be associated with this OperationgetState()
Gets the current state of this operationvoid
resume()
Resumes this operation on the current thread.void
resume
(long threadId) Resumes this operation on the given thread id.void
setOperationData
(Object data) Sets arbitrary Operation data to be associated with this Operationvoid
suspend()
Suspends this operation on the current thread.void
suspend
(long threadId) Suspends this operation on the given thread id.
-
Method Details
-
getIdentifier
OperationIdentifier<T> getIdentifier()Returns a unique identifier for this operation- Returns:
- A non-null unique identifier for this operation
-
getState
OperationState getState()Gets the current state of this operation- Returns:
- The current state of this operation
-
getActiveThreads
Gets a set of threads upon which this Operation is active- Returns:
- The set of threads upon which this Operation is active
-
suspend
void suspend(long threadId) Suspends this operation on the given thread id. If this Operation is not associated with the given threadId this method does nothing- Parameters:
threadId
- The thread on which to suspend this operation
-
suspend
void suspend()Suspends this operation on the current thread. If this Operation is not associated with the current threadId this method does nothing -
resume
Resumes this operation on the given thread id. If this Operation is already associated with the given threadId this method does nothing- Parameters:
threadId
- The thread on which to resume this operation- Throws:
IllegalStateException
- if the Operation is closed or if the given thread is associated with a different Operation of the same type
-
resume
Resumes this operation on the current thread. If this Operation is already associated with the current thread this method does nothing- Throws:
IllegalStateException
- if the Operation is closed or if the current thread is associated with a different Operation of the same type
-
closeOperation
void closeOperation()suspends this Operation on all threads where it is associated and closes the operation. All resume calls on this handle after this is called will throw IllegalStateException. If this handle is already closed this method does nothing -
getOperationData
Object getOperationData()Gets arbitrary Operation data to be associated with this Operation- Returns:
- Arbitrary (possibly null) data that is associated with this Operation
-
setOperationData
Sets arbitrary Operation data to be associated with this Operation- Parameters:
data
- (possibly null) data that is associated with this Operation
-