net.sf.farrago.util
Class FarragoCacheEntry

java.lang.Object
  extended by net.sf.farrago.util.FarragoCacheEntry
All Implemented Interfaces:
FarragoAllocation, FarragoObjectCache.Entry, FarragoObjectCache.UninitializedEntry, ClosableAllocation

public class FarragoCacheEntry
extends Object
implements FarragoObjectCache.Entry, FarragoObjectCache.UninitializedEntry

FarragoCacheEntry implements the interfaces for a cache entry.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/util/FarragoCacheEntry.java#10 $

Field Summary
(package private)  Thread constructionThread
           
(package private)  boolean isInitialized
           
(package private)  boolean isReusable
           
(package private)  Object key
           
(package private)  AtomicLong memoryUsage
           
(package private)  FarragoObjectCache parentCache
          The cache this entry is associated with
(package private)  int pinCount
           
(package private)  Object value
           
 
Constructor Summary
FarragoCacheEntry(FarragoObjectCache parentCache)
           
 
Method Summary
 void closeAllocation()
          Closes this object.
 Object getKey()
           
 Object getValue()
           
 void initialize(Object value, long memoryUsage, boolean isReusable)
          Initializes the entry.
(package private)  boolean isInitialized()
           
 boolean isReusable()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

key

Object key

value

Object value

pinCount

int pinCount

memoryUsage

AtomicLong memoryUsage

constructionThread

Thread constructionThread

isReusable

boolean isReusable

isInitialized

boolean isInitialized

parentCache

FarragoObjectCache parentCache
The cache this entry is associated with

Constructor Detail

FarragoCacheEntry

public FarragoCacheEntry(FarragoObjectCache parentCache)
Method Detail

getKey

public Object getKey()
Specified by:
getKey in interface FarragoObjectCache.Entry
Returns:
the key of this entry (as passed to the FarragoObjectCache.pin(java.lang.Object, net.sf.farrago.util.FarragoObjectCache.CachedObjectFactory, boolean) method).

getValue

public Object getValue()
Specified by:
getValue in interface FarragoObjectCache.Entry
Returns:
the value cached by this entry (as set by FarragoObjectCache.UninitializedEntry.initialize(java.lang.Object, long, boolean)).

isReusable

public boolean isReusable()

initialize

public void initialize(Object value,
                       long memoryUsage,
                       boolean isReusable)
Description copied from interface: FarragoObjectCache.UninitializedEntry
Initializes the entry.

Specified by:
initialize in interface FarragoObjectCache.UninitializedEntry
Parameters:
value - the value to associate with the entry's key; if this Object implements FarragoAllocation, it will be closed when discarded from the cache
memoryUsage - approximate total number of bytes of memory used by entry (combination of key, value, and any sub-objects)
isReusable - whether the initialized entry is reusable; if false, the entry will be returned as private to the original caller of FarragoObjectCache.pin(java.lang.Object, net.sf.farrago.util.FarragoObjectCache.CachedObjectFactory, boolean), and no other callers will ever be able to pin it

closeAllocation

public void closeAllocation()
Description copied from interface: ClosableAllocation
Closes this object.

Specified by:
closeAllocation in interface ClosableAllocation

toString

public String toString()
Overrides:
toString in class Object

isInitialized

boolean isInitialized()
Returns:
whether initialize(java.lang.Object, long, boolean) has been called yet