Java类动态代理框架 Smartproxy
fmms
13年前
<p>Smartproxy 是一个 Java 的动态类和实例代理框架,类似 java.lang.reflect.Proxy 类所作的工作,但无需调用 InvocationHandler 接口。Smartproxy 通过底层对象提供对抽象类方法的重载。Smartproxy 使用 BCEL 类库。</p> <ul> <li>Easy to use since there is not need to code an invocation handler, only the methods to be changed in the proxy.</li> <li>Fast to execute since the smartproxy generated classes actually inherit from the abstract class and actually implement (in byte code) the delegation calls to the underlying object. As a result a proxy class generated by smartproxy is roughly equivalent to the same hand coded class while the jlrP generated classes are way slower (on a first test about 100 time slower on my machine).</li> </ul> <p>示例代码:</p> <p></p> <pre class="brush:java; toolbar: true; auto-links: false;">// Create the proxy factory for the set on interface/implementor. ProxyFactory factory = ProxyFactory.getInstance(SimpleImplementor.class, SimpleInterface.class); // Creates an underlying object. SimpleInterface base = new SimpleBaseClass(); // Proxify the underlying object. SimpleInterface proxified = (SimpleInterface) factory.createProxy(new Object[] { base });</pre> <br /> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326987539608" target="_blank">http://www.open-open.com/lib/view/home/1326987539608</a></p>