我想使用方面为私有 id 字段添加 getter 和 setter。我知道如何通过方面添加方法,但是如何访问私有 id 字段?
我认为我只需要使方面得到授权。我尝试了以下代码,但方面无法访问 id 字段。
public privileged aspect MyAspect {
public String Item.getId(){
return this.id;
}
一种可能性是用户反映,如本博客文章所示:http: //blog.m1key.me/2011/05/aop-aspectj-field-access-to-inejct.html
反射是唯一的可能性还是有办法用 AspectJ 做到这一点?