I currently have the following class
com.mystuff.otherlib
class MyClass<k, v> {
// constructor and some functions
// method I want to monitor
public void onReceive(Mtype<k, v> event) {
}
}
I am working on a spring project and there are several beans of this type and some of these beans have the same k and v type.
However I want to monitor the execution of onReceieve() for a specific bean called beanA. It is important to note that MyClass is in a library which I have on my classpath. I use maven as a build tool. I make the beans in the current project but the class declaration is in a library.
I use the following technique to monitor the execution.
@Configuration
@EnableAspectJProxy(proxyTargetClass = true)
@Aspect
class MyAspectConfig {
@Before("bean(beanA) && execution(* com.mystuff.otherlib.MyClass.onReceive(*)) && args(receieved)")
public void onReceiving(Mtype<Mkey, Mvalue> receieved) {
// do something
}
}
As you can see I am trying to specify the bean and the type. However onReceiving does not get called when onReceived(Mtype<Mkey, Mvalue>) is called in bean beanA. beanA is basically of type MyClass<Mkey, Mvalue>. I am wondering if I need to do load time weaving ?