org.apache.ojb.broker.cache
Class AbstractMetaCache

java.lang.Object
  extended by org.apache.ojb.broker.cache.AbstractMetaCache
All Implemented Interfaces:
ObjectCache
Direct Known Subclasses:
ObjectCacheJCSPerClassImpl, ObjectCachePerClassImpl

public abstract class AbstractMetaCache
extends java.lang.Object
implements ObjectCache

An abstract 'meta' implementation of the ObjectCache interace.
Implement the abstract getCache(org.apache.ojb.broker.Identity, java.lang.Object, int) method in sub-classes. All base Object/Identity validation is done by this class.

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

Field Summary
static int METHOD_CACHE
           
static int METHOD_LOOKUP
           
static int METHOD_REMOVE
           
 
Constructor Summary
AbstractMetaCache()
           
 
Method Summary
 void cache(Identity oid, java.lang.Object obj)
          Caches the given object using the given Identity as key
 boolean cacheIfNew(Identity oid, java.lang.Object obj)
          We delegate this method to the standard cache method.
abstract  ObjectCache getCache(Identity oid, java.lang.Object obj, int callingMethod)
          This method handle all calls against the ObjectCache interface.
 java.lang.Object lookup(Identity oid)
          Looks up the object from the cache
 void remove(Identity oid)
          Removes the given object from the cache
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.ojb.broker.cache.ObjectCache
clear
 

Field Detail

METHOD_CACHE

public static final int METHOD_CACHE
See Also:
Constant Field Values

METHOD_LOOKUP

public static final int METHOD_LOOKUP
See Also:
Constant Field Values

METHOD_REMOVE

public static final int METHOD_REMOVE
See Also:
Constant Field Values
Constructor Detail

AbstractMetaCache

public AbstractMetaCache()
Method Detail

getCache

public abstract ObjectCache getCache(Identity oid,
                                     java.lang.Object obj,
                                     int callingMethod)
This method handle all calls against the ObjectCache interface. Note: The parameter obj can be null - e.g. when lookup or remove method was called.

Parameters:
oid - Identity of the target object.
obj - The target object itself or null if not available.
callingMethod - Specifies the type of method call against the ObjectCache interface. METHOD_CACHE, METHOD_LOOKUP, METHOD_REMOVE.
Returns:
The ObjectCache implementation.

cache

public void cache(Identity oid,
                  java.lang.Object obj)
Caches the given object using the given Identity as key

Specified by:
cache in interface ObjectCache
Parameters:
oid - The Identity key
obj - The object o cache

cacheIfNew

public boolean cacheIfNew(Identity oid,
                          java.lang.Object obj)
We delegate this method to the standard cache method.
++ Override if needed ++


lookup

public java.lang.Object lookup(Identity oid)
Looks up the object from the cache

Specified by:
lookup in interface ObjectCache
Parameters:
oid - The Identity to look up the object for
Returns:
The object if found, otherwise null

remove

public void remove(Identity oid)
Removes the given object from the cache

Specified by:
remove in interface ObjectCache
Parameters:
oid - oid of the object to remove


(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