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, AliasDescriptor, AutoActiveDescriptor, ConfigBean, ConstantActiveDescriptor, ConstantActiveDescriptor, Dom, DomDescriptor, ExistingSingletonInhabitant, 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

Author:
jwells

Method Summary
 T getCache()
          This can be used for scopes that will only every be created once.
 boolean isCacheSet()
          Returns true if this cache has been set
 void releaseCache()
          Removes the cached value and makes it such that this cache has not been set
 void 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



Copyright © 2013 Oracle Corporation. All Rights Reserved.