org.apache.ojb.broker.cache
Interface ObjectCacheInternal

All Superinterfaces:
ObjectCache
All Known Implementing Classes:
MaterializationCache, ObjectCacheDefaultImpl, ObjectCacheTwoLevelImpl

public interface ObjectCacheInternal
extends ObjectCache

Internal used extension of the ObjectCache.

Version:
$Id: ObjectCacheInternal.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Armin Waibel

Field Summary
static int TYPE_CACHED_READ
          Object was read from a cache entity (e.g. from a second-level cache).
static int TYPE_NEW_MATERIALIZED
          Object was new materialized from persistence storage.
static int TYPE_TEMP
          Object caching type used for temporary storage of objects, these objects will never be pushed to a higher level cache.
static int TYPE_UNKNOWN
          Object caching type was unkown.
static int TYPE_WRITE
          Object was update or insert.
 
Method Summary
 boolean cacheIfNew(Identity oid, java.lang.Object obj)
          For internal use within ObjectCache implementations or to build two-level caches.
 void doInternalCache(Identity oid, java.lang.Object obj, int type)
          For internal use.
 
Methods inherited from interface org.apache.ojb.broker.cache.ObjectCache
cache, clear, lookup, remove
 

Field Detail

TYPE_WRITE

static final int TYPE_WRITE
Object was update or insert.

See Also:
Constant Field Values

TYPE_CACHED_READ

static final int TYPE_CACHED_READ
Object was read from a cache entity (e.g. from a second-level cache).

See Also:
Constant Field Values

TYPE_NEW_MATERIALIZED

static final int TYPE_NEW_MATERIALIZED
Object was new materialized from persistence storage.

See Also:
Constant Field Values

TYPE_UNKNOWN

static final int TYPE_UNKNOWN
Object caching type was unkown.

See Also:
Constant Field Values

TYPE_TEMP

static final int TYPE_TEMP
Object caching type used for temporary storage of objects, these objects will never be pushed to a higher level cache.

See Also:
Constant Field Values
Method Detail

doInternalCache

void doInternalCache(Identity oid,
                     java.lang.Object obj,
                     int type)
For internal use. This method have to be used by all OJB classes to cache objects. It allows to decide if an object should be cached or not. Useful for two level caches to reduce object copy costs.


cacheIfNew

boolean cacheIfNew(Identity oid,
                   java.lang.Object obj)
For internal use within ObjectCache implementations or to build two-level caches. Handle with care.

Used to cache new objects (not already cached) by it's Identity. This method was used to cache new materialized objects and should work as a "atomic" method (the check and the put of the object should be atomic) to avoid concurrency problems.

Currently it's not mandatory that all ObjectCache implementations support this method, so in some cases it's allowed to delegate this method call to the standard cache.

Parameters:
oid - Identity of the object to cache.
obj - The object to cache.
Returns:
If object was added true, else false.


(C) 2002 - 2006 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