use of net.sf.cglib.proxy.MethodInterceptor in project cxf by apache.
the class CglibProxyHelper method getProxyInternal.
@Override
protected Object getProxyInternal(ClassLoader loader, Class<?>[] interfaces, final java.lang.reflect.InvocationHandler h) {
Class<?> superClass = null;
List<Class<?>> theInterfaces = new ArrayList<Class<?>>();
for (Class<?> c : interfaces) {
if (!c.isInterface()) {
if (superClass != null) {
throw new IllegalArgumentException("Only a single superclass is supported");
}
superClass = c;
} else {
theInterfaces.add(c);
}
}
if (superClass != null) {
Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(loader);
enhancer.setSuperclass(superClass);
enhancer.setInterfaces(theInterfaces.toArray(new Class<?>[theInterfaces.size()]));
enhancer.setCallback(new MethodInterceptor() {
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
return h.invoke(obj, method, args);
}
});
return enhancer.create();
}
return super.getProxyInternal(loader, interfaces, h);
}
Aggregations