biz.hammurapi.cache
Class SoftCachingProxyFactory

java.lang.Object
  extended by biz.hammurapi.cache.SoftCachingProxyFactory

public class SoftCachingProxyFactory
extends java.lang.Object

Creates proxy which caches return values of getXXX() method invocations in soft references

Author:
Pavel

Constructor Summary
SoftCachingProxyFactory()
           
 
Method Summary
static java.lang.Object createCachingProxy(java.lang.Object master)
          Creates proxy which caches return values of getXXX() method invocations in soft references.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftCachingProxyFactory

public SoftCachingProxyFactory()
Method Detail

createCachingProxy

public static java.lang.Object createCachingProxy(java.lang.Object master)
Creates proxy which caches return values of getXXX() method invocations in soft references. Return values are keyed by method declaring type, method name, parameter types, and parameter values. Internal map is not cleaned up when SoftReference is cleared and entries do not have expiration time. Cache entries are invalidated when non-getXXX method is invoked and if that method is not declared by Object (i.e. hashCode() or equals() do not invalidate cache). The proxy prevent repeated invocations of the same method with same arguments from multiple threads. I.e. if one thread invoked a method and method invocation is in progress, other threads invoking same method with same parameters during method invocation will block and will receive the same return value.

Returns:
Caching proxy or master, if master doesn't implement any interfaces.


Copyright © 2003 Hammurapi Group. All Rights Reserved.