2013-04-01 92 views
0

如何看看Spring的創建/生成接口實現InvocationHandler然後創建一個代理對象?spring AOP JDKdynamicAopProxy InvocationHandler

代理對象有一個構造函數,它被稱爲本實施

public Proxy(InvocationHandler paramInvocationHandler) { 

    super(paramInvocationHandler); 

} 
+0

Eclipse調試器? –

+0

debug允許看到代碼? – rdm

+0

你有一個maven項目嗎? –

回答

0

JDKdynamicAopProxy是實現的InvocationHandler的。 這是創建代理對象的普通方法。

public Object getProxy(ClassLoader classLoader) { 
    if (logger.isDebugEnabled()) { 
     logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource()); 
    } 
    Class[] proxiedInterfaces = AopProxyUtils.completeProxiedInterfaces(this.advised); 
    findDefinedEqualsAndHashCodeMethods(proxiedInterfaces); 
    return Proxy.newProxyInstance(classLoader, proxiedInterfaces, this); 
} 

只需調用帶有classLoader,接口,InvocationHandler的args的Proxy方法即可。