Class ConfiguredByContext
- java.lang.Object
-
- org.glassfish.hk2.configuration.internal.ConfiguredByContext
-
- All Implemented Interfaces:
Context<ConfiguredBy>
@Singleton @Visibility(LOCAL) public class ConfiguredByContext extends java.lang.Object implements Context<ConfiguredBy>
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<ActiveDescriptor<?>,java.lang.Object>dbprivate java.lang.Objectlockprivate static java.lang.ThreadLocal<ActiveDescriptor<?>>workingOn
-
Constructor Summary
Constructors Constructor Description ConfiguredByContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.(package private) java.lang.ObjectfindOnly(ActiveDescriptor<?> descriptor)<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.java.lang.Class<? extends java.lang.annotation.Annotation>getScope()The scope for which this is the context(package private) ActiveDescriptor<?>getWorkingOn()private <U> UinternalFindOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)booleanisActive()True if this context is active, false otherwisevoidshutdown()Shut down this context.booleansupportsNullCreation()Returns true if the findOrCreate method can return null
-
-
-
Field Detail
-
workingOn
private static final java.lang.ThreadLocal<ActiveDescriptor<?>> workingOn
-
lock
private final java.lang.Object lock
-
db
private final java.util.HashMap<ActiveDescriptor<?>,java.lang.Object> db
-
-
Method Detail
-
getScope
public java.lang.Class<? extends java.lang.annotation.Annotation> getScope()
Description copied from interface:ContextThe scope for which this is the context- Specified by:
getScopein interfaceContext<ConfiguredBy>- Returns:
- may not return null, must return the scope for which this is a context
-
findOrCreate
public <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
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<ConfiguredBy>- 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
-
internalFindOrCreate
private <U> U internalFindOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
-
containsKey
public boolean containsKey(ActiveDescriptor<?> descriptor)
Description copied from interface:ContextDetermines if this context has a value for the given key- Specified by:
containsKeyin interfaceContext<ConfiguredBy>- Parameters:
descriptor- The descriptor to look for in this context- Returns:
- true if this context has a value associated with this descriptor
-
destroyOne
public void destroyOne(ActiveDescriptor<?> descriptor)
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<ConfiguredBy>- Parameters:
descriptor- A non-null descriptor upon whichServiceHandle.destroy()has been called
-
supportsNullCreation
public boolean supportsNullCreation()
Description copied from interface:ContextReturns true if the findOrCreate method can return null- Specified by:
supportsNullCreationin interfaceContext<ConfiguredBy>- 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<ConfiguredBy>- Returns:
- true if this context is active, false otherwise
-
shutdown
public void shutdown()
Description copied from interface:ContextShut down this context.- Specified by:
shutdownin interfaceContext<ConfiguredBy>
-
getWorkingOn
ActiveDescriptor<?> getWorkingOn()
-
findOnly
java.lang.Object findOnly(ActiveDescriptor<?> descriptor)
-
-