Package org.glassfish.hk2.utilities
Class ImmediateContext
- java.lang.Object
-
- org.glassfish.hk2.utilities.ImmediateContext
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<ActiveDescriptor<?>,java.lang.Long>
creating
private java.util.HashMap<ActiveDescriptor<?>,HandleAndService>
currentImmediateServices
private ServiceLocator
locator
private Filter
validationFilter
-
Constructor Summary
Constructors Modifier Constructor Description private
ImmediateContext(ServiceLocator locator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(ActiveDescriptor<?> descriptor)
Determines if this context has a value for the given keyvoid
destroyOne(ActiveDescriptor<?> descriptor)
This method is called whenServiceHandle.destroy()
method is called.private void
destroyOne(ActiveDescriptor<?> descriptor, java.util.List<ImmediateErrorHandler> errorHandlers)
Destroys a single descriptorvoid
doWork()
<U> U
findOrCreate(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.private java.util.List<ActiveDescriptor<?>>
getImmediateServices()
java.lang.Class<? extends java.lang.annotation.Annotation>
getScope()
The scope for which this is the contextFilter
getValidationFilter()
boolean
isActive()
True if this context is active, false otherwisevoid
shutdown()
For when the server shuts downboolean
supportsNullCreation()
Returns true if the findOrCreate method can return null
-
-
-
Field Detail
-
currentImmediateServices
private final java.util.HashMap<ActiveDescriptor<?>,HandleAndService> currentImmediateServices
-
creating
private final java.util.HashMap<ActiveDescriptor<?>,java.lang.Long> creating
-
locator
private final ServiceLocator locator
-
validationFilter
private final Filter validationFilter
-
-
Constructor Detail
-
ImmediateContext
@Inject private ImmediateContext(ServiceLocator locator)
-
-
Method Detail
-
getScope
public java.lang.Class<? extends java.lang.annotation.Annotation> getScope()
Description copied from interface:Context
The scope for which this is the context
-
findOrCreate
public <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
Description copied from interface:Context
Creates 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:
findOrCreate
in interfaceContext<Immediate>
- Parameters:
activeDescriptor
- The descriptor to createroot
- The root handle- Returns:
- The service
-
containsKey
public boolean containsKey(ActiveDescriptor<?> descriptor)
Description copied from interface:Context
Determines if this context has a value for the given key- Specified by:
containsKey
in interfaceContext<Immediate>
- Parameters:
descriptor
- The descriptor to find- Returns:
- true if this service has been created
-
destroyOne
public void destroyOne(ActiveDescriptor<?> descriptor)
Description copied from interface:Context
This 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:
destroyOne
in interfaceContext<Immediate>
- Parameters:
descriptor
- A non-null descriptor upon whichServiceHandle.destroy()
has been called
-
destroyOne
private void destroyOne(ActiveDescriptor<?> descriptor, java.util.List<ImmediateErrorHandler> errorHandlers)
Destroys a single descriptor- Parameters:
descriptor
- The descriptor to destroyerrorHandlers
- The handlers for exceptions (if null will get from service locator)
-
supportsNullCreation
public boolean supportsNullCreation()
Description copied from interface:Context
Returns true if the findOrCreate method can return null- Specified by:
supportsNullCreation
in interfaceContext<Immediate>
- Returns:
- true if null is a legal value from the findOrCreate method
-
isActive
public boolean isActive()
Description copied from interface:Context
True if this context is active, false otherwise
-
shutdown
public void shutdown()
For when the server shuts down
-
getImmediateServices
private java.util.List<ActiveDescriptor<?>> getImmediateServices()
-
getValidationFilter
public Filter getValidationFilter()
-
doWork
public void doWork()
-
-