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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
getCache()
This can be used for scopes that will only every be created once.boolean
isCacheSet()
Returns true if this cache has been setvoid
releaseCache()
Removes the cached value and makes it such that this cache has not been setvoid
setCache(T cacheMe)
Sets the value into the cache
-
-
-
Method Detail
-
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
void setCache(T cacheMe)
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
-
-