I would like to use aspectj to profile the library. My plan was to mark methods that require profiling with annotation:
@Profiled("logicalUnitOfWork")
And then you have an aspect that will fire before and after methods that will use logicalUnitOfWork to highlight profiled content.
So, my pointcut for starters looks like this. Note that there is no argument for annotation; that one of the things i'm not sure how to do is:
pointcut profiled() : execution(@Profiled * *()); before() : profiled () { // : the profiled logical name is in this variable: String logicalEventType; Profiler.startEvent (logicalEventType); } after() returning : profiled() { // : the profiled logical name is in this variable: String logicalEventType; Profiler.endEvent (logicalEventType); }
The methods used will be defined as follows:
@Profiled("someAction") public void doAction (args...) {}
In short, how can I get the value of @Profiled annotation in an aspect? I donβt need to limit which profiling is based on value, I just need it to be visible for advice. Also, do I need the annotation hold to be set at runtime for this to work, or can I instead save at class level?
source share