Using Java Dynamic Agent Class implementation method cache

xiaoxiao2021-03-06  49

Today, I saw an article, explaining how to use Java dynamic proxy implementation to cache

http://www.matrix.org.cn/Article/487.html

After reading the following understanding:

First of all, his cache is targeted

InvocationHandler implements an instance of an object to caches instead of global. Each Memoizer.Memoize method call will regenerate an Memoizer instance. public static Object memoize (Object object) {return Proxy.newProxyInstance (. object.getClass () getClassLoader (), object.getClass () getInterfaces (), new Memoizer (object).);} method object.getClass (). GetInterfaces () usage is flexible, realizing dynamic instances of any objects and interfaces. This is also an implementation of AOP based on dynamic agents.

转载请注明原文地址:https://www.9cbs.com/read-59654.html

New Post(0)