我有 SomeInterface 的几个实现。问题是,在 SomeInterface 的所有实现中,executeSomething 方法的切入点是什么。
public class SomeImplementation implements SomeInterface {
public String executeSomething(String parameter) {
// Do something
}
}
public class AnotherImplementation implements SomeInterface {
public String executeSomething(String parameter) {
// Do something different way
}
}
该方法的切入点可以是方法执行或方法调用切入点。满足您的要求的最具体的切入点如下所示:
execution(public String SomeInterface+.executeSomething(String))
call(public String SomeInterface+.executeSomething(String))
关于这些切入点类型的一些解释:
- 这两个切入点中使用的类型模式意味着:所有返回的公共方法
String
定义在SomeInterface
或其任何子类型,被命名为executeSomething
并接受单个String
争论。这是可以为您的情况定义的最具体的类型模式,它将仅匹配String SomeInterface.executeSomething(String)
method.
- 执行类型切入点匹配特定方法体执行时对应的连接点
- 调用类型切入点匹配特定方法被调用时对应的连接点(即连接点位于调用方)
执行类型切入点更常用,但调用类型切入点在某些情况下也非常有用。
See AspectJ 语言/连接点和切入点 https://eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html#call-vs-execution中的章节AspectJ 编程指南 https://eclipse.org/aspectj/doc/released/progguide/index.html供进一步参考。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)