1 package org.shiftone.cache; 2 3 4 5 import org.shiftone.cache.util.CacheInvocationHandler; 6 7 import java.lang.reflect.InvocationHandler ; 8 import java.lang.reflect.Proxy ; 9 10 11 24 public class CacheProxy 25 { 26 27 private static final ClassLoader DEFAULT_CLASS_LOADER = CacheProxy.class.getClassLoader(); 28 29 public static Object newProxyInstance(ClassLoader loader, Object target, Class iface, Cache cache) throws IllegalArgumentException 30 { 31 32 InvocationHandler handler = null; 33 Class [] ifaces = new Class []{ iface }; 34 35 handler = new CacheInvocationHandler(target, cache); 36 37 return Proxy.newProxyInstance(loader, ifaces, handler); 38 } 39 40 41 public static Object newProxyInstance(Object target, Class iface, Cache cache) throws IllegalArgumentException 42 { 43 return newProxyInstance(DEFAULT_CLASS_LOADER, target, iface, cache); 44 } 45 } 46 | Popular Tags |