返回(aspect)接口方法中的类实例

时间:2014-02-18 15:48:07

标签: java interface aspectj aop implements

我正在从一个方面实现一个接口

declare parents: SomePackage.AClass+ extends InterfaceBelow

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

我想要一个应该返回实现接口本身的类/实例的方法。诸如向接口public Object getSelf()添加方法然后使用AspectJ来实现它的东西:

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

我需要在不是来自班级的方面进行,然后{return this;}

1 个答案:

答案 0 :(得分:1)

InterfaceBelow.getSelf()返回null。然后围绕该方法创建around切入点。切入点可以捕获方法调用的target。返回那个。

相关问题