Top Inners Fields Constructors Methods
org.jvnet.hk2.internal

public Class SingletonContext

extends Object
implements Context<Singleton>
Class Inheritance
All Implemented Interfaces
org.glassfish.hk2.api.Context
Annotations
@Singleton
Imports
java.io.Serializable, java.lang.annotation.Annotation, java.util.Comparator, .List, .TreeSet, java.util.concurrent.locks.ReentrantLock, jakarta.inject.Singleton, org.glassfish.hk2.api.ActiveDescriptor, .Context, .MultiException, .ServiceHandle, org.glassfish.hk2.utilities.BuilderHelper, .ContextualInput, org.glassfish.hk2.utilities.cache.Cache, .Computable, org.glassfish.hk2.utilities.reflection.Logger

Author
jwells

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private int
private final ServiceLocatorImpl
private final ReentrantLock
private final Cache<ContextualInput<Object>, Object>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
containsKey(ActiveDescriptor<?> descriptor)

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

Determines if this context has a value for the given key

public void
destroyOne(ActiveDescriptor<?>
The descriptor to release (may not be null). Further, the cache MUST be set
one
)

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

Release one system descriptor

public <T> T
findOrCreate(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> 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.

public Class<? extends Annotation>
getScope()

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

The scope for which this is the context

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.

Shut down this context.

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

generationNumberback to summary
private int generationNumber
locatorback to summary
private final ServiceLocatorImpl locator
lockback to summary
private final ReentrantLock lock
valueCacheback to summary
private final Cache<ContextualInput<Object>, Object> valueCache

Constructor Detail

SingletonContextback to summary
pack-priv SingletonContext(ServiceLocatorImpl impl)

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

Annotations
@SuppressWarnings:unchecked
@Override
destroyOneback to summary
public void destroyOne(ActiveDescriptor<?> one)

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

Release one system descriptor

Parameters
one:ActiveDescriptor<?>

The descriptor to release (may not be null). Further, the cache MUST be set

Annotations
@SuppressWarnings:unchecked
@Override
findOrCreateback to summary
public <T> T findOrCreate(ActiveDescriptor<T> 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

Annotations
@SuppressWarnings:unchecked
@Override
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
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.

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

Shut down this context.

Annotations
@SuppressWarnings:unchecked
@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
org.jvnet.hk2.internal back to summary

private Class SingletonContext.GenerationComparator

extends Object
implements Comparator<SystemDescriptor<Object>>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

For serialization

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(SystemDescriptor<Object> o1, SystemDescriptor<Object> o2)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

For serialization

Constructor Detail

GenerationComparatorback to summary
private GenerationComparator()

Method Detail

compareback to summary
public int compare(SystemDescriptor<Object> o1, SystemDescriptor<Object> o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Annotations
@Override