Interface OperationHandle<T extends Annotation>

  • All Known Implementing Classes:
    OperationHandleImpl

    @Contract
    public interface OperationHandle<T extends Annotation>
    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
    Author:
    jwells
    • Method Detail

      • 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

        Set<Long> 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

        void resume​(long threadId)
             throws IllegalStateException
        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

        void resume()
             throws IllegalStateException
        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

        void setOperationData​(Object data)
        Sets arbitrary Operation data to be associated with this Operation
        Parameters:
        data - (possibly null) data that is associated with this Operation