public class ObjectCacheLocalDefaultImpl extends java.lang.Object implements ObjectCache
ObjectCache
implementation using a
HashMap
to cache given objects.
The cache uses soft-references which allows objects (softly) referenced by the cache to be reclaimed by the Java Garbage Collector when they are not longer referenced elsewhere.
NOTE: Handle with care! If multiple PB instances are used (OJB standard behavior) you will run into synchronization problems.
Implementation configuration properties:
Property Key | Property Values |
timeout | Lifetime of the cached objects in seconds. If expired the cached object was not returned on lookup call (and removed from cache). |
Constructor and Description |
---|
ObjectCacheLocalDefaultImpl(PersistenceBroker broker,
java.util.Properties prop) |
Modifier and Type | Method and Description |
---|---|
void |
cache(Identity oid,
java.lang.Object obj)
Makes object persistent to the Objectcache.
|
boolean |
cacheIfNew(Identity oid,
java.lang.Object obj) |
void |
clear()
Clear ObjectCache.
|
java.lang.Object |
lookup(Identity oid)
Lookup object with Identity oid in objectTable.
|
void |
remove(Identity oid)
Removes an Object from the cache.
|
java.lang.String |
toString() |
public ObjectCacheLocalDefaultImpl(PersistenceBroker broker, java.util.Properties prop)
public void clear()
clear
in interface ObjectCache
public void cache(Identity oid, java.lang.Object obj)
cache
in interface ObjectCache
oid
- Identity of the object to cache.obj
- The object to cache.public boolean cacheIfNew(Identity oid, java.lang.Object obj)
public java.lang.Object lookup(Identity oid)
lookup
in interface ObjectCache
oid
- Identity of the object to search for.Identity
is found.public void remove(Identity oid)
remove
in interface ObjectCache
oid
- Identity of the object to be removed.public java.lang.String toString()
toString
in class java.lang.Object
(C) 2002 - 2005 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30