Returning an instance of a class in an interface (aspect) method

I am implementing an interface from an aspect

declare parents: SomePackage.AClass+ extends InterfaceBelow

public interface InterfaceBelow() {
        //bunch of methods
}

I need a method that should return a class / instance that implements the interface itself. Something like adding a method to an interface public Object getSelf(), and then use AspectJ to implement it as follows:

public InterfaceBelow.getSelf()
{
     //how to return the instance implementing the interface
}

I need to do this in an aspect not from the class, and then {return this;}

+3
source share
1 answer

have InterfaceBelow.getSelf()return null. then create a pointcut aroundaround this method. pointcut can capture a targetmethod call. return it instead.

+1
source

All Articles