内部方法调用的方面
我有一个要求,我需要在内部方法调用周围放置一个方面,内部的意思是
class Person{
public void outerMethod()
{
internalMethod()
}
// Need an aspect here !!
public void internalMethod()
{
}
}
我知道使用传统的 spring aop 是不可能的,本机方面 j 是否为此提供了设施?我可以指点一下吗
I have a requirement where in I need to place an aspect around an internal method call, by internal I mean
class Person{
public void outerMethod()
{
internalMethod()
}
// Need an aspect here !!
public void internalMethod()
{
}
}
I am aware that this is not possible using conventional spring aop, does native aspectj provide a facility for this ? and can I have pointers for the same
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然可以:
或者
您可以将其中任何一个与
before
、after
或around
建议结合起来:请注意,这是传统的切面语法,您可以使用在 .aj 文件中使用。您还可以在 @AspectJ .java 语法中使用具有不同语法的所有这些构造。
请参阅AspectJ 快速参考或阅读AspectJ 实际应用
Sure thing:
Or
You can combine either of these with
before
,after
oraround
advices:Note this is traditional aspectj-Syntax, the one you use in .aj files. You can also use all of these constructs with different Syntax in @AspectJ .java syntax.
Please consult the AspectJ Quick Reference or read AspectJ in Action
我只会添加我自己问题的答案。
最重要的是这不能通过spring aop实现,
可以通过aspectJ实现,当我尝试aspectj的loadtime weaving时似乎没有提供解决方案。 (这还没有完全研究)...我发现它作为切面放置在对象周围..因此通过对象进行的所有调用都调用了切面,但是内部调用没有调用切面
只有编译时编织可以解决这个问题。
这里也提出了同样的问题
谢谢
苏达山
I'll just add an answer to my own question.
The most important thing is this cannot be achieved through spring aop,
It can be achieved by aspectJ , when I tried out loadtime weaving of aspectj it did not seem to provide a solution. (This is not completely researched) ... What i found was that it placed as aspect around the object .. so all calls made through the object invoked the aspect, however internal calls did not invoke the aspect
Only compile time weaving can resolve this.
the same question is asked here too
Thanks
Sudarshan
参考此文档并使用
执行< /code> 或
call
切入点和around
建议。根据您描述的任务,它们完全适合您的需求。Reference to this documentation and use
execution
orcall
pointcuts andaround
advice. As far as you described your task they perfectly suit your needs.