I'm developing a framework in Spring boot, that is used by some applications. In some point at runtime, the application supply me (the framework)
an instance of class A
, that I want to aspect (using spring) its func
method.
The problem is, that I am not the one who construct this instace so I can't create it by applicationContext.getBean(A.class)
.
Is there a way to give Spring this instance and tell it to make it (or proxy it with) a bean?
public interface A {
void func(int i);
}
Aspect:
@Aspect
public class AspectClass {
@Around("execution(*com.A.func(..))")
public void funcAspect(ProceedingJoinPoint joinPoint) throws Throwable {
....
}
}
I expect it to be something like: A bean = applicationContext.makeBean(instanceOfA)
EDIT: I can't control the construction of A
, I'm not the one who construct it, and I just get its existing instance and want to aspect its func
method, from now on.