Interface OperationManager
-
- All Known Implementing Classes:
OperationManagerImpl
@Contract public interface OperationManager
Manages HK2 operations, allowing the user to create new operations of a particular type or discover the current set of active operations or find the current operation on the current threadOperations are categorized by the Annotation type. The annotation type corresponds to the annotation class used in the extension of the
OperationContext
which defines the scope of the Operation. Most of the methods for this service take an implementation of that annotation class, which is usually implemented by extendingAnnotationLiteral
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends java.lang.annotation.Annotation>
OperationHandle<T>createAndStartOperation(T scope)
Creates an OperationHandle that will be associated with the thread calling this method.<T extends java.lang.annotation.Annotation>
OperationHandle<T>createOperation(T scope)
Creates an OperationHandle.<T extends java.lang.annotation.Annotation>
OperationHandle<T>getCurrentOperation(T scope)
Gets the current operation of scope type on the current thread.<T extends java.lang.annotation.Annotation>
java.util.Set<OperationHandle<T>>getCurrentOperations(T scope)
Gets a set of all Operations that are in stateOperationState.ACTIVE
orOperationState.SUSPENDED
.void
shutdownAllOperations(java.lang.annotation.Annotation scope)
This method will suspend all currently open operations on all threads and then close them.
-
-
-
Method Detail
-
createOperation
<T extends java.lang.annotation.Annotation> OperationHandle<T> createOperation(T scope)
Creates an OperationHandle. The returned handle will not be associated with any threads. The scope parameter is normally created withAnnotationLiteral
- Parameters:
scope
- The scope annotation for this operation type- Returns:
- A non-null OperationHandle that can be used to associate threads with the Operation
-
createAndStartOperation
<T extends java.lang.annotation.Annotation> OperationHandle<T> createAndStartOperation(T scope)
Creates an OperationHandle that will be associated with the thread calling this method. The scope parameter is normally created withAnnotationLiteral
- Parameters:
scope
- The scope annotation for this operation type- Returns:
- A non-null OperationHandle that can be used to associate threads with the Operation
- Throws:
java.lang.IllegalStateException
- if the current thread is associated with a different Operation of the same type
-
getCurrentOperations
<T extends java.lang.annotation.Annotation> java.util.Set<OperationHandle<T>> getCurrentOperations(T scope)
Gets a set of all Operations that are in stateOperationState.ACTIVE
orOperationState.SUSPENDED
. Operations that are in theOperationState.CLOSED
state are no longer tracked by the Manager. The scope parameter is normally created withAnnotationLiteral
- Parameters:
scope
- The scope annotation for this operation type- Returns:
- A non-null but possibly empty set of OperationHandles that have not been closed
-
getCurrentOperation
<T extends java.lang.annotation.Annotation> OperationHandle<T> getCurrentOperation(T scope)
Gets the current operation of scope type on the current thread. The scope parameter is normally created withAnnotationLiteral
- Parameters:
scope
- The scope annotation for this operation type- Returns:
- The current operation of the given type on this thread. May be null if there is no active operation on this thread of this type
-
shutdownAllOperations
void shutdownAllOperations(java.lang.annotation.Annotation scope)
This method will suspend all currently open operations on all threads and then close them. This will also remove all entities associated with this operation type, including the OperationHandle associated with this scope from the HK2 locator service registry. Therefore this mechanism of shutting down the operations should be used with care, and would normally only be used when the Operation type can never be used again.The scope parameter is normally created with
AnnotationLiteral
- Parameters:
scope
- The scope annotation for this operation type
-
-