Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to get the enclosing class in a Pointcut

Bump 😊


So no input on this one?


br,


//mike


 

 




Från: Mikael Petterson <mikaelpetterson@xxxxxxxxxxx>
Skickat: den 18 september 2017 13:27
Till: aspectj-users@xxxxxxxxxxx
Ämne: How to get the enclosing class in a Pointcut
 

Hi,


I have started to look into aspectj , now that I have a working dev environment in Eclipse 😊


I want to find which classes and methods  outside our application that calls to our application classes with public methods that has annotation @Deprecated.


I have created the following 'pointcut':


pointcut deprecatedMethods() : call(public * *.*(..)) && @withincode(Deprecated);
    before() : deprecatedMethods() {
      log("[Deprecated Method Usage]" +" --> "+ thisEnclosingJoinPointStaticPart.getSignature().toShortString+"\n");

    }


The above will give something like:


[Deprecated Method Usage] --> HandlerImpl.getBoards(..)


 I can see which classes' methods with @Deprecated gets called. But I cannot see  what the name of the enclosing class and method is, in this case Demo.test() ( see below).


  1. Is it possible to get this using aspectj?
  2. What would be the correct pointcut to use?


br.


//mike



public class Demo extends Test{

    @Test
    public void test() {
      Node node = new Node();
      Handler handler = node.getObjectHandler();
      //getBoards() is the deprecated method.
      Boards boards = handler.getBoards();
     
 
    }
}


 

 


Back to the top