Class OperationContext<T extends Annotation>
- All Implemented Interfaces:
Context<T>
Context for an Operation.
An operation is defined as a unit of work that can be associated with one or more java threads, but where two operations of the same type may not be associated with the same thread at the same time. Examples of such an operation might be a RequestScope or a TenantRequesteOperation. An operation is a more general concept than the normal Java EE request scope, since it does not require a Java EE container
Users of this API generally create a Scope annotation
and extend this class, implementing the Context.getScope()
and making sure the parameterized type is the Scope annotation.
The Scope annotation for an Operation is usually
Proxiable but does not have to be. As with all implementations
of Context the subclass of this class must be in the
invalid reference
SingletonInjectsPerRequestOperationManager and OperationHandle
to start and stop Operations and to associate and dis-associate
threads with Operations
Classes extending this class may also choose to override the method
Context.supportsNullCreation() which returns false by default
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashMap<Long, LinkedList<OperationHandleImpl<T>>> private final HashSet<ActiveDescriptor<?>> private SingleOperationManager<T> private final HashMap<OperationHandleImpl<T>, LinkedHashMap<ActiveDescriptor<?>, Object>> private boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseOperation(OperationHandleImpl<T> operation) booleancontainsKey(ActiveDescriptor<?> descriptor) Determines if this context has a value for the given keyvoiddestroyOne(ActiveDescriptor<?> descriptor) This method is called whenServiceHandle.destroy()method is called.<U> UfindOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root) Creates a contextual instance of this ActiveDescriptor by calling its create method if there is no other matching contextual instance.booleanisActive()True if this context is active, false otherwisevoidsetOperationManager(SingleOperationManager<T> manager) voidshutdown()Shut down this context.booleanReturns true if the findOrCreate method can return nulltoString()
-
Field Details
-
manager
-
operationMap
private final HashMap<OperationHandleImpl<T extends Annotation>,LinkedHashMap<ActiveDescriptor<?>, operationMapObject>> -
creating
-
closingOperations
-
shuttingDown
private boolean shuttingDown
-
-
Constructor Details
-
OperationContext
public OperationContext()
-
-
Method Details
-
findOrCreate
Description copied from interface:ContextCreates a contextual instance of this ActiveDescriptor by calling its create method if there is no other matching contextual instance. If there is already a contextual instance it is returned. If parent is null then this must work like the find call- Specified by:
findOrCreatein interfaceContext<T extends Annotation>- Parameters:
activeDescriptor- The descriptor to use when creating instancesroot- The extended provider for the outermost parent being created- Returns:
- A context instance. This value may NOT be null
-
containsKey
Description copied from interface:ContextDetermines if this context has a value for the given key- Specified by:
containsKeyin interfaceContext<T extends Annotation>- Parameters:
descriptor- The descriptor to look for in this context- Returns:
- true if this context has a value associated with this descriptor
-
destroyOne
Description copied from interface:ContextThis method is called whenServiceHandle.destroy()method is called. It is up to the context implementation whether or not to honor this destruction request based on the lifecycle requirements of the context- Specified by:
destroyOnein interfaceContext<T extends Annotation>- Parameters:
descriptor- A non-null descriptor upon whichServiceHandle.destroy()has been called
-
closeOperation
-
shutdown
public void shutdown()Description copied from interface:ContextShut down this context.- Specified by:
shutdownin interfaceContext<T extends Annotation>
-
supportsNullCreation
public boolean supportsNullCreation()Description copied from interface:ContextReturns true if the findOrCreate method can return null- Specified by:
supportsNullCreationin interfaceContext<T extends Annotation>- Returns:
- true if null is a legal value from the findOrCreate method
-
isActive
public boolean isActive()Description copied from interface:ContextTrue if this context is active, false otherwise- Specified by:
isActivein interfaceContext<T extends Annotation>- Returns:
- true if this context is active, false otherwise
-
setOperationManager
-
toString
-