Package org.jvnet.hk2.internal
Class SingletonContext
- java.lang.Object
-
- org.jvnet.hk2.internal.SingletonContext
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SingletonContext.GenerationComparator
-
Field Summary
Fields Modifier and Type Field Description private int
generationNumber
private ServiceLocatorImpl
locator
private Cache<ContextualInput<java.lang.Object>,java.lang.Object>
valueCache
-
Constructor Summary
Constructors Constructor Description SingletonContext(ServiceLocatorImpl impl)
-
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<?> one)
Release one system descriptor<T> T
findOrCreate(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> root)
Creates a contextual instance of this ActiveDescriptor by calling its create method if there is no other matching contextual instance.java.lang.Class<? extends java.lang.annotation.Annotation>
getScope()
The scope for which this is the contextboolean
isActive()
True if this context is active, false otherwisevoid
shutdown()
Shut down this context.boolean
supportsNullCreation()
Returns true if the findOrCreate method can return null
-
-
-
Field Detail
-
generationNumber
private int generationNumber
-
locator
private final ServiceLocatorImpl locator
-
valueCache
private final Cache<ContextualInput<java.lang.Object>,java.lang.Object> valueCache
-
-
Constructor Detail
-
SingletonContext
SingletonContext(ServiceLocatorImpl impl)
-
-
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 <T> T findOrCreate(ActiveDescriptor<T> 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<javax.inject.Singleton>
- 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
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<javax.inject.Singleton>
- Parameters:
descriptor
- The descriptor to look for in this context- Returns:
- true if this context has a value associated with this descriptor
-
isActive
public boolean isActive()
Description copied from interface:Context
True if this context is active, false otherwise
-
supportsNullCreation
public boolean supportsNullCreation()
Description copied from interface:Context
Returns true if the findOrCreate method can return null- Specified by:
supportsNullCreation
in interfaceContext<javax.inject.Singleton>
- Returns:
- true if null is a legal value from the findOrCreate method
-
shutdown
public void shutdown()
Description copied from interface:Context
Shut down this context.
-
destroyOne
public void destroyOne(ActiveDescriptor<?> one)
Release one system descriptor- Specified by:
destroyOne
in interfaceContext<javax.inject.Singleton>
- Parameters:
one
- The descriptor to release (may not be null). Further, the cache MUST be set
-
-