fstab / promagent

Prometheus Monitoring for Java Web Applications without Modifying their Source Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to declare generic parameter type in Hook methods

cool-dude-9 opened this issue · comments

I am trying to create hook methods for my project, the hook method arguments are not primitive data types, they are typically different type of classes in my project. If I have to declare my Hook methods in Hook classes, I am forced to make all the parameter classes available during the compilation. Will there be any simple way to declaring generic hook methods with generic parameter types where the actual parameter type is not available during Hook classes compilation?

To be more specific, how can I create a hook without providing someclass.test.com class file when I am compiling the Hook classes.
hook method : someMethod (someclass.test.com param1)

There is a work around for this , I can create dummy classes in Hook class files and proceed. I have tested this with Promagent and its working so you can close the issue.

Great to hear that you found a way to make it work. To clarify (for other people who might find this): In the hook methods you specify the parameter types of the method you want to instrument. If an other parameter type is passed in at runtime (like your method accepts class List and at runtime you get an ArrayList) it will work. The important thing is that the method signature of your hook is the same as the method signature of the class you are instrumenting.