本帖最后由 Jam-l 于 2013-9-28 20:11 编辑
- public class ProxyFactoryBean {
- private Advice advice;
- private Object target;
-
- public void setAdvice(Advice advice) {
- this.advice = advice;
- }
- public void setTarget(Object target) {
- this.target = target;
- }
- public Object getProxy() {
- return Proxy.newProxyInstance(
- target.getClass().getClassLoader(),
- target.getClass().getInterfaces(),
- new InvocationHandler() {
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- advice.beforeMethod(method);
- Object objVal = method.invoke(target, args);
- advice.afterMethod(method);
- return objVal;
- }
- });
- }
- }
复制代码 代码中定义了两个成员变量,到底动态代理的是哪个变量? 这两个变量分别代表什么意思?
|