Class OperationHandleImpl<T extends java.lang.annotation.Annotation>
- java.lang.Object
-
- org.glassfish.hk2.extras.operation.internal.OperationHandleImpl<T>
-
- All Implemented Interfaces:
OperationHandle<T>
public class OperationHandleImpl<T extends java.lang.annotation.Annotation> extends java.lang.Object implements OperationHandle<T>
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashSet<java.lang.Long>activeThreadsprivate OperationIdentifier<T>identifierprivate java.lang.ObjectoperationLockprivate SingleOperationManager<T>parentprivate OperationStatestateprivate java.lang.ObjectuserData
-
Constructor Summary
Constructors Constructor Description OperationHandleImpl(SingleOperationManager<T> parent, OperationIdentifier<T> identifier, java.lang.Object operationLock, ServiceLocator locator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckState()voidcloseOperation()suspends this Operation on all threads where it is associated and closes the operation.booleanequals(java.lang.Object o)java.util.Set<java.lang.Long>getActiveThreads()Gets a set of threads upon which this Operation is activeOperationIdentifier<T>getIdentifier()Returns a unique identifier for this operationjava.lang.ObjectgetOperationData()Gets arbitrary Operation data to be associated with this OperationOperationStategetState()Gets the current state of this operationinthashCode()voidresume()Resumes this operation on the current thread.voidresume(long threadId)Resumes this operation on the given thread id.voidsetOperationData(java.lang.Object data)Sets arbitrary Operation data to be associated with this Operation(package private) voidshutdownByFiat()operationLock must be heldvoidsuspend()Suspends this operation on the current thread.voidsuspend(long threadId)Suspends this operation on the given thread id.java.lang.StringtoString()
-
-
-
Field Detail
-
parent
private final SingleOperationManager<T extends java.lang.annotation.Annotation> parent
-
identifier
private final OperationIdentifier<T extends java.lang.annotation.Annotation> identifier
-
operationLock
private final java.lang.Object operationLock
-
state
private OperationState state
-
activeThreads
private final java.util.HashSet<java.lang.Long> activeThreads
-
userData
private java.lang.Object userData
-
-
Constructor Detail
-
OperationHandleImpl
OperationHandleImpl(SingleOperationManager<T> parent, OperationIdentifier<T> identifier, java.lang.Object operationLock, ServiceLocator locator)
-
-
Method Detail
-
getIdentifier
public OperationIdentifier<T> getIdentifier()
Description copied from interface:OperationHandleReturns a unique identifier for this operation- Specified by:
getIdentifierin interfaceOperationHandle<T extends java.lang.annotation.Annotation>- Returns:
- A non-null unique identifier for this operation
-
getState
public OperationState getState()
Description copied from interface:OperationHandleGets the current state of this operation- Specified by:
getStatein interfaceOperationHandle<T extends java.lang.annotation.Annotation>- Returns:
- The current state of this operation
-
shutdownByFiat
void shutdownByFiat()
operationLock must be held
-
checkState
private void checkState()
-
getActiveThreads
public java.util.Set<java.lang.Long> getActiveThreads()
Description copied from interface:OperationHandleGets a set of threads upon which this Operation is active- Specified by:
getActiveThreadsin interfaceOperationHandle<T extends java.lang.annotation.Annotation>- Returns:
- The set of threads upon which this Operation is active
-
suspend
public void suspend(long threadId)
Description copied from interface:OperationHandleSuspends this operation on the given thread id. If this Operation is not associated with the given threadId this method does nothing- Specified by:
suspendin interfaceOperationHandle<T extends java.lang.annotation.Annotation>- Parameters:
threadId- The thread on which to suspend this operation
-
suspend
public void suspend()
Description copied from interface:OperationHandleSuspends this operation on the current thread. If this Operation is not associated with the current threadId this method does nothing- Specified by:
suspendin interfaceOperationHandle<T extends java.lang.annotation.Annotation>
-
resume
public void resume(long threadId) throws java.lang.IllegalStateExceptionDescription copied from interface:OperationHandleResumes this operation on the given thread id. If this Operation is already associated with the given threadId this method does nothing- Specified by:
resumein interfaceOperationHandle<T extends java.lang.annotation.Annotation>- Parameters:
threadId- The thread on which to resume this operation- Throws:
java.lang.IllegalStateException- if the Operation is closed or if the given thread is associated with a different Operation of the same type
-
resume
public void resume() throws java.lang.IllegalStateExceptionDescription copied from interface:OperationHandleResumes this operation on the current thread. If this Operation is already associated with the current thread this method does nothing- Specified by:
resumein interfaceOperationHandle<T extends java.lang.annotation.Annotation>- Throws:
java.lang.IllegalStateException- if the Operation is closed or if the current thread is associated with a different Operation of the same type
-
closeOperation
public void closeOperation()
Description copied from interface:OperationHandlesuspends 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- Specified by:
closeOperationin interfaceOperationHandle<T extends java.lang.annotation.Annotation>
-
getOperationData
public java.lang.Object getOperationData()
Description copied from interface:OperationHandleGets arbitrary Operation data to be associated with this Operation- Specified by:
getOperationDatain interfaceOperationHandle<T extends java.lang.annotation.Annotation>- Returns:
- Arbitrary (possibly null) data that is associated with this Operation
-
setOperationData
public void setOperationData(java.lang.Object data)
Description copied from interface:OperationHandleSets arbitrary Operation data to be associated with this Operation- Specified by:
setOperationDatain interfaceOperationHandle<T extends java.lang.annotation.Annotation>- Parameters:
data- (possibly null) data that is associated with this Operation
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-