@Singleton @Visibility(value=LOCAL) public class ConfiguredByContext extends java.lang.Object implements Context<ConfiguredBy>
Modifier and Type | Field and Description |
---|---|
private java.util.HashMap<ActiveDescriptor<?>,java.lang.Object> |
db |
private java.lang.Object |
lock |
private static java.lang.ThreadLocal<ActiveDescriptor<?>> |
workingOn |
Constructor and Description |
---|
ConfiguredByContext() |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(ActiveDescriptor<?> descriptor)
Determines if this context has a value for the given key
|
void |
destroyOne(ActiveDescriptor<?> descriptor)
This method is called when
ServiceHandle.destroy() method is called. |
(package private) java.lang.Object |
findOnly(ActiveDescriptor<?> descriptor) |
<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.
|
java.lang.Class<? extends java.lang.annotation.Annotation> |
getScope()
The scope for which this is the context
|
(package private) ActiveDescriptor<?> |
getWorkingOn() |
private <U> U |
internalFindOrCreate(ActiveDescriptor<U> activeDescriptor,
ServiceHandle<?> root) |
boolean |
isActive()
True if this context is active, false otherwise
|
void |
shutdown()
Shut down this context.
|
boolean |
supportsNullCreation()
Returns true if the findOrCreate method can return null
|
private static final java.lang.ThreadLocal<ActiveDescriptor<?>> workingOn
private final java.lang.Object lock
private final java.util.HashMap<ActiveDescriptor<?>,java.lang.Object> db
public java.lang.Class<? extends java.lang.annotation.Annotation> getScope()
Context
getScope
in interface Context<ConfiguredBy>
public <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
Context
findOrCreate
in interface Context<ConfiguredBy>
activeDescriptor
- The descriptor to use when creating instancesroot
- The extended provider for the outermost parent being createdprivate <U> U internalFindOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
public boolean containsKey(ActiveDescriptor<?> descriptor)
Context
containsKey
in interface Context<ConfiguredBy>
descriptor
- The descriptor to look for in this contextpublic void destroyOne(ActiveDescriptor<?> descriptor)
Context
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 contextdestroyOne
in interface Context<ConfiguredBy>
descriptor
- A non-null descriptor upon which ServiceHandle.destroy()
has been calledpublic boolean supportsNullCreation()
Context
supportsNullCreation
in interface Context<ConfiguredBy>
public boolean isActive()
Context
isActive
in interface Context<ConfiguredBy>
public void shutdown()
Context
shutdown
in interface Context<ConfiguredBy>
ActiveDescriptor<?> getWorkingOn()
java.lang.Object findOnly(ActiveDescriptor<?> descriptor)