bearcatjs / bearcat

powered by enhanced javaScript objects
http://bearcatjs.org/
Other
591 stars 110 forks source link

aop 依赖注入bean对象引用报错!! #204

Closed zj8487 closed 9 years ago

zj8487 commented 9 years ago

重现过程: 1,使用官方的例子:bearcat/examples/aop_annotation 在car.js 中删除dyInit 函数。使得该用例能work

2,在Aspect中引用wheel

var Aspect = function() {
        this.$id = "aspect";
        this.$aop = true;
        this.$wheel = null;
}

3,测试该例子报错: [2015-07-01 16:01:55.499] [ERROR] bearcat - [BeanFactory] circle reference beanName aspect is in creating

4,wheel没有任何对象引用,不存在循环引用。

fantasyni commented 9 years ago
var Wheel = function() {
    this.$id = "wheel";
    this.$proxy = false;
}

Wheel.prototype.doWheel = function() {

}

module.exports = Wheel;

这个因为是基础的bean,wheel是不能被aspect切入的,所以要设置 proxy 为 false

zj8487 commented 9 years ago

aspect 只是切入了car,并没有切入wheel啊!

zj8487 commented 9 years ago

难道aspect会去检查每一个bean,不管是否需要切入?

fantasyni commented 9 years ago

对的,默认切入,wheel 切入 aspect 就循环了

zj8487 commented 9 years ago

难怪,那我只是对几个bean切入。其他的所有bean都他要加上this.$proxy = false; 我试试看

zj8487 commented 9 years ago

it works