org.kuali.rice.kns.util.cache
Class MethodCacheNoCopyInterceptor

java.lang.Object
  extended by org.kuali.rice.kns.util.cache.MethodCacheNoCopyInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.InitializingBean

public class MethodCacheNoCopyInterceptor
extends Object
implements org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.InitializingBean

begin Kuali Foundation modification This class implements org.aopalliance.intercept.MethodInterceptor. This interceptor builds the cache key for the method and checks if an earlier result was cached with that key. If so, the cached result is returned; otherwise, the intercepted method is called and the result cached for future use. end Kuali Foundation modification

Since:
2004.10.07
Author:
Kuali Rice Team (rice.collab@kuali.org)

Constructor Summary
MethodCacheNoCopyInterceptor()
           
 
Method Summary
 void afterPropertiesSet()
          Checks if required attributes are provided.
 String buildCacheKey(String methodSignature, Object[] argValues)
           
 boolean containsCacheKey(String key)
           
 Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
          begin Kuali Foundation modification Caches method results, if possible.
 void removeCacheKey(String cacheKey)
          Removes a method cache if one exists for the given key.
 void setCache(com.opensymphony.oscache.base.Cache cache)
          begin Kuali Foundation modification
 void setExpirationTimeInSeconds(int expirationTimeInSeconds)
          Entries older than this will have their contents replaced by the return value from a call to the appropriate method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodCacheNoCopyInterceptor

public MethodCacheNoCopyInterceptor()
Method Detail

setCache

public void setCache(com.opensymphony.oscache.base.Cache cache)
begin Kuali Foundation modification

Parameters:
cache - name of cache to be used end Kuali Foundation modification

setExpirationTimeInSeconds

public void setExpirationTimeInSeconds(int expirationTimeInSeconds)
Entries older than this will have their contents replaced by the return value from a call to the appropriate method

Parameters:
expirationTimeInSeconds -

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Checks if required attributes are provided. begin Kuali Foundation modification

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception
See Also:
end Kuali Foundation modification

invoke

public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
              throws Throwable
begin Kuali Foundation modification Caches method results, if possible.

Results must be Serializable to be cached. Method with unSerializable results will never have their results cached, and will log error messages complaining about that fact.

Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Throws:
Throwable
See Also:
end Kuali Foundation modification

buildCacheKey

public String buildCacheKey(String methodSignature,
                            Object[] argValues)
Parameters:
className -
methodName -
paramTypes -
argValues -
Returns:
cache key: className.methodName(paramClass=argValue[,paramClass=argValue...])

containsCacheKey

public boolean containsCacheKey(String key)
Parameters:
key -
Returns:
true if the cache contains an entry with the given key

removeCacheKey

public void removeCacheKey(String cacheKey)
Removes a method cache if one exists for the given key.

Parameters:
cacheKey - - key for method signature and parameters - see buildCacheKey


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.