Let's consider that I have some Class A which has property of class B.
public class ClassA{
private ClassB classB;
public ClassA(ClassB classB){
this.classB = classB;
}
//some methods ommitted.
}
No I have CGLIB proxy:
public class CGLibProxy implements MethodInterceptor{
@Override
public Object intercept(Object object, Method method, Object[] args,
MethodProxy methodProxy) throws Throwable {
if (method.getName().startsWith("print")){
System.out.println("We will not run any method started with print");
return null;
}
else
return methodProxy.invokeSuper(object, args);
}
}
Now, When I use CGLib
for ClassA , proxy creates ClassA instance.
My question is how can I pass classB parameter to this proxy, because as far As I understand CGLib will run empty constructor for ClassA?