SmartproxyJava類動(dòng)態(tài)代理框架
Smartproxy 是一個(gè) Java 的動(dòng)態(tài)類和實(shí)例代理框架,類似 java.lang.reflect.Proxy 類所作的工作,但無需調(diào)用 InvocationHandler 接口。Smartproxy 通過底層對(duì)象提供對(duì)抽象類方法的重載。Smartproxy 使用 BCEL 類庫(kù)。
示例代碼:
// 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 });
評(píng)論
圖片
表情
