Package org.glassfish.hk2.api
Interface SingleCache<T>
- Type Parameters:
T
- The type of service stored and returned from this cache
- All Known Subinterfaces:
ActiveDescriptor<T>
- All Known Implementing Classes:
AbstractActiveDescriptor
,ActiveDescriptorBuilderImpl.BuiltActiveDescriptor
,AliasDescriptor
,AutoActiveDescriptor
,ConstantActiveDescriptor
,ConstantActiveDescriptor
,CrossOverDescriptor
,DelegatingNamedActiveDescriptor
,OperationDescriptor
,SystemDescriptor
public interface SingleCache<T>
This cache can be used in some circumstances when there can be only one
of a service. This is useful and can avoid an expensive lookup in certain
context implementations
-
Method Summary
Modifier and TypeMethodDescriptiongetCache()
This can be used for scopes that will only every be created once.boolean
Returns true if this cache has been setvoid
Removes the cached value and makes it such that this cache has not been setvoid
Sets the value into the cache
-
Method Details
-
getCache
T getCache()This can be used for scopes that will only every be created once. The returned value must have been set previously with setCache. If this is called when isCacheSet is false will result in a RuntimeException- Returns:
- A value cached with this ActiveDescriptor
-
isCacheSet
boolean isCacheSet()Returns true if this cache has been set- Returns:
- true if there is a currently cached value, false otherwise
-
setCache
Sets the value into the cache- Parameters:
cacheMe
- A single value that can be cached in this active descriptor
-
releaseCache
void releaseCache()Removes the cached value and makes it such that this cache has not been set
-