OK, I've written a class that allows OSCache to work with OJB. Here's a short how to:
(Thomas, you might add this to the Contrib with that other class I did for Tangosol caching.) 1) First, download OSCache and javagroups from the following links: http://www.opensymphony.com/oscache/download.html http://www.javagroups.com/javagroupsnew/docs/index.html 2) put oscache.jar and javagroups.jar in your classpath 3) Add oscache.properties somewhere where it can be accessed (classpath, or WEB-INF/classes or whatever). This file allows you different configurations (disk/memory caching, algorithms, etc). Please go to the following for more info on that: http://www.opensymphony.com/oscache/ 4) Change the ObjectCacheClass value to ObjectCacheOSCacheImpl (you may want to change the package name if you add package level info to the class). 5) add the Class that I've included to the proper package as described in step 4 (again you may want to change packages). NOTES: This is somewhat tested. I ran about 20 different tests on it and it worked fine for a local cache. But I haven't really kicked it too hard yet. NOTES2: I have not yet gotten the cluster feature of OSCache working. There is something wrong with one of the listeners, and I'm working on it. So the cache is working fine locally, but not clustered/distributed. Let me know about questions/comments. Jason ---------------------------HERE'S THAT CLASS---------------------------- import org.apache.ojb.broker.Identity; import org.apache.ojb.broker.PersistenceBroker; import org.apache.ojb.broker.cache.ObjectCache; import org.apache.ojb.broker.cache.RuntimeCacheException; import com.opensymphony.oscache.base.CacheEntry; import com.opensymphony.oscache.general.GeneralCacheAdministrator; import java.util.Date; public class ObjectCacheOSCacheImpl implements ObjectCache { private GeneralCacheAdministrator admin; private static final int NO_REFRESH_NEEDED = CacheEntry.INDEFINITE_EXPIRY; public ObjectCacheOSCacheImpl() { } public ObjectCacheOSCacheImpl(PersistenceBroker broker) { admin = new GeneralCacheAdministrator(); } public void cache(Identity oid, Object obj) { try { admin.putInCache(oid.toString(), obj); } catch (Exception e) { throw new RuntimeCacheException(e.getMessage()); } } public Object lookup(Identity oid) { try { return admin.getFromCache(oid.toString(), NO_REFRESH_NEEDED); } catch (Exception e) { return null; } } public void remove(Identity oid) { try { admin.getCache().flushEntry(oid.toString()); } catch (Exception e) { throw new RuntimeCacheException(e.getMessage()); } } public void clear() { if (admin != null) { try { admin.flushAll(new Date()); } catch (Exception e) { throw new RuntimeCacheException(e); } } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
