Top Description Fields Constructors Methods
org.glassfish.hk2.utilities

public Class ImmediateContext

extends Object
implements Context<Immediate>
Class Inheritance
All Implemented Interfaces
org.glassfish.hk2.api.Context
Annotations
@Singleton
@Visibility:LOCAL
Imports
java.lang.annotation.Annotation, java.util.Collections, .HashMap, .HashSet, .LinkedHashSet, .List, .Map, java.util.concurrent.locks.Condition, .ReentrantLock, jakarta.inject.Inject, .Singleton, org.glassfish.hk2.api.ActiveDescriptor, .Context, .DescriptorVisibility, .Filter, .Immediate, .MultiException, .ServiceHandle, .ServiceLocator, .Visibility, org.glassfish.hk2.internal.HandleAndService, .ImmediateLocalLocatorFilter

This is the Context implementation for the Immediate scope
Author
jwells

Field Summary

Modifier and TypeField and Description
private final HashMap<ActiveDescriptor<?>, Long>
private final HashMap<ActiveDescriptor<?>, HandleAndService>
private final ServiceLocator
private final ReentrantLock
private final Condition
private final Filter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this service has been created
containsKey
(ActiveDescriptor<?>
The descriptor to find
descriptor
)

Implements org.glassfish.hk2.api.Context.containsKey.

Determines if this context has a value for the given key

public void
destroyOne(ActiveDescriptor<?> descriptor)

Implements org.glassfish.hk2.api.Context.destroyOne.

This method is called when ServiceHandle#destroy() method is called.

private void
destroyOne(ActiveDescriptor<?>
The descriptor to destroy
descriptor
,
List<ImmediateErrorHandler>
The handlers for exceptions (if null will get from service locator)
errorHandlers
)

Destroys a single descriptor

public void
public <U> U

Returns:

The service
findOrCreate
(ActiveDescriptor<U>
The descriptor to create
activeDescriptor
,
ServiceHandle<?>
The root handle
root
)

Implements org.glassfish.hk2.api.Context.findOrCreate.

Creates a contextual instance of this ActiveDescriptor by calling its create method if there is no other matching contextual instance.

private List<ActiveDescriptor<?>>
public Class<? extends Annotation>
getScope()

Implements org.glassfish.hk2.api.Context.getScope.

The scope for which this is the context

public Filter
public boolean
isActive()

Implements org.glassfish.hk2.api.Context.isActive.

True if this context is active, false otherwise

public void
shutdown()

Implements org.glassfish.hk2.api.Context.shutdown.

For when the server shuts down

public boolean
supportsNullCreation()

Implements org.glassfish.hk2.api.Context.supportsNullCreation.

Returns true if the findOrCreate method can return null

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

creatingback to summary
private final HashMap<ActiveDescriptor<?>, Long> creating
currentImmediateServicesback to summary
private final HashMap<ActiveDescriptor<?>, HandleAndService> currentImmediateServices
locatorback to summary
private final ServiceLocator locator
lockback to summary
private final ReentrantLock lock
notEmptyback to summary
private final Condition notEmpty
validationFilterback to summary
private final Filter validationFilter

Constructor Detail

ImmediateContextback to summary
private ImmediateContext(ServiceLocator locator)
Annotations
@Inject

Method Detail

containsKeyback to summary
public boolean containsKey(ActiveDescriptor<?> descriptor)

Implements org.glassfish.hk2.api.Context.containsKey.

Doc from org.glassfish.hk2.api.Context.containsKey.

Determines if this context has a value for the given key

Parameters
descriptor:ActiveDescriptor<?>

The descriptor to find

Returns:boolean

true if this service has been created

Annotations
@Override
destroyOneback to summary
public void destroyOne(ActiveDescriptor<?> descriptor)

Implements org.glassfish.hk2.api.Context.destroyOne.

Doc from org.glassfish.hk2.api.Context.destroyOne.

This method is called when ServiceHandle#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

Annotations
@Override
destroyOneback to summary
private void destroyOne(ActiveDescriptor<?> descriptor, List<ImmediateErrorHandler> errorHandlers)

Destroys a single descriptor

Parameters
descriptor:ActiveDescriptor<?>

The descriptor to destroy

errorHandlers:List<ImmediateErrorHandler>

The handlers for exceptions (if null will get from service locator)

Annotations
@SuppressWarnings:unchecked
doWorkback to summary
public void doWork()
findOrCreateback to summary
public <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)

Implements org.glassfish.hk2.api.Context.findOrCreate.

Doc from org.glassfish.hk2.api.Context.findOrCreate.

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

Parameters
activeDescriptor:ActiveDescriptor<U>

The descriptor to create

root:ServiceHandle<?>

The root handle

Returns:U

The service

Annotations
@Override
@SuppressWarnings:unchecked
getImmediateServicesback to summary
private List<ActiveDescriptor<?>> getImmediateServices()
getScopeback to summary
public Class<? extends Annotation> getScope()

Implements org.glassfish.hk2.api.Context.getScope.

Doc from org.glassfish.hk2.api.Context.getScope.

The scope for which this is the context

Annotations
@Override
getValidationFilterback to summary
public Filter getValidationFilter()
isActiveback to summary
public boolean isActive()

Implements org.glassfish.hk2.api.Context.isActive.

Doc from org.glassfish.hk2.api.Context.isActive.

True if this context is active, false otherwise

Annotations
@Override
shutdownback to summary
public void shutdown()

Implements org.glassfish.hk2.api.Context.shutdown.

For when the server shuts down

Annotations
@Override
supportsNullCreationback to summary
public boolean supportsNullCreation()

Implements org.glassfish.hk2.api.Context.supportsNullCreation.

Doc from org.glassfish.hk2.api.Context.supportsNullCreation.

Returns true if the findOrCreate method can return null

Annotations
@Override