ozone core API

org.ozoneDB.core.storage
Class AbstractReferenceCache

java.lang.Object
  extended byorg.ozoneDB.core.storage.AbstractReferenceCache
All Implemented Interfaces:
Cache, PropertyConfigurable
Direct Known Subclasses:
SoftReferenceCache, WeakReferenceCache

public abstract class AbstractReferenceCache
extends java.lang.Object
implements Cache, PropertyConfigurable

Version:
$Id: AbstractReferenceCache.java,v 1.2.2.2 2004/04/10 10:06:51 per_nyfelt Exp $
Author:
Leo Mekenkamp (mind the anti sp@m)

Nested Class Summary
protected static interface AbstractReferenceCache.KeyedReference
          We need to find objects in the map that holds the references.
private  class AbstractReferenceCache.ReferenceHandler
          Handles the garbage collector 'messages' that certain softly reachable objects have been gc-ed.
 
Field Summary
private  java.util.Map map
          backing map (key -> (ObjectReference -> cached object))
private  java.lang.String prefix
           
private  AbstractReferenceCache.ReferenceHandler referenceHandler
           
private  java.lang.ref.ReferenceQueue referenceQueue
           
 
Constructor Summary
protected AbstractReferenceCache()
           
  AbstractReferenceCache(java.util.Properties properties, java.lang.String prefix)
           
 
Method Summary
 java.util.Map copyToMap()
           
protected abstract  AbstractReferenceCache.KeyedReference createKeyedReference(java.lang.Object key, java.lang.Object value, java.lang.ref.ReferenceQueue referenceQueue)
           
 java.lang.Object get(java.lang.Object key)
          Returns the object in this cache for the given key.
private  java.util.Map getMap()
           
 java.lang.String getPrefix()
           
 java.util.Collection getPropertyInfos()
          Returns a Collection with all the properties this instance supports.
private  java.lang.ref.ReferenceQueue getReferenceQueue()
           
 void put(java.lang.Object key, java.lang.Object value)
          Puts an object into the cache, along with its identifying key.
 java.lang.Object remove(java.lang.Object key)
          Returns the object in this cache for the given key and removes it from the cache.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

referenceQueue

private java.lang.ref.ReferenceQueue referenceQueue

referenceHandler

private AbstractReferenceCache.ReferenceHandler referenceHandler

prefix

private java.lang.String prefix

map

private java.util.Map map
backing map (key -> (ObjectReference -> cached object))

Constructor Detail

AbstractReferenceCache

public AbstractReferenceCache(java.util.Properties properties,
                              java.lang.String prefix)

AbstractReferenceCache

protected AbstractReferenceCache()
Method Detail

createKeyedReference

protected abstract AbstractReferenceCache.KeyedReference createKeyedReference(java.lang.Object key,
                                                                              java.lang.Object value,
                                                                              java.lang.ref.ReferenceQueue referenceQueue)

get

public java.lang.Object get(java.lang.Object key)
Description copied from interface: Cache
Returns the object in this cache for the given key.

Specified by:
get in interface Cache

put

public void put(java.lang.Object key,
                java.lang.Object value)
Description copied from interface: Cache
Puts an object into the cache, along with its identifying key.

Specified by:
put in interface Cache

remove

public java.lang.Object remove(java.lang.Object key)
Description copied from interface: Cache
Returns the object in this cache for the given key and removes it from the cache.

Specified by:
remove in interface Cache

copyToMap

public java.util.Map copyToMap()
Specified by:
copyToMap in interface Cache

getMap

private java.util.Map getMap()

getReferenceQueue

private java.lang.ref.ReferenceQueue getReferenceQueue()

size

public int size()
Specified by:
size in interface Cache

getPrefix

public java.lang.String getPrefix()
Specified by:
getPrefix in interface PropertyConfigurable

getPropertyInfos

public java.util.Collection getPropertyInfos()
Description copied from interface: PropertyConfigurable

Returns a Collection with all the properties this instance supports.

Specified by:
getPropertyInfos in interface PropertyConfigurable
Returns:
Collection with PropertyInfo elements

ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.