1、工具类
package com.mvc.common.util.proxy;
import java.lang.reflect.Method;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
public abstract class AbstractMethodInterceptor implements MethodInterceptor {
private Object target = null;
private Object proxTarget = null;
public AbstractMethodInterceptor(Object target) {
super();
this.target = target;
Enhancer e = new Enhancer();
e.setSuperclass(target.getClass());
e.setCallback(this);
this.proxTarget = e.create();
}
public Object getPoxy() {
return this.proxTarget;
}
public Object getTarget() {
return this.target;
}
abstract public Object intercept(Object object, Method method,
Object[] args, MethodProxy proxy) throws Throwable;
}