Top Description Methods
org.glassfish.hk2.api

public Interface SingleCache<T>

Known Direct Subinterfaces
org.glassfish.hk2.api.ActiveDescriptor
Type Parameters
<T>
The type of service stored and returned from this cache

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

Modifier and TypeMethod and Description
public T

Returns:

A value cached with this ActiveDescriptor
getCache
()

This can be used for scopes that will only every be created once.

public boolean

Returns:

true if there is a currently cached value, false otherwise
isCacheSet
()

Returns true if this cache has been set

public void
releaseCache()

Removes the cached value and makes it such that this cache has not been set

public void
setCache(T
A single value that can be cached in this active descriptor
cacheMe
)

Sets the value into the cache

Method Detail

getCacheback to summary
public 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:T

A value cached with this ActiveDescriptor

isCacheSetback to summary
public boolean isCacheSet()

Returns true if this cache has been set

Returns:boolean

true if there is a currently cached value, false otherwise

releaseCacheback to summary
public void releaseCache()

Removes the cached value and makes it such that this cache has not been set

setCacheback to summary
public void setCache(T cacheMe)

Sets the value into the cache

Parameters
cacheMe:T

A single value that can be cached in this active descriptor