Closed GoogleCodeExporter closed 9 years ago
第一个问题, 已经有相关的issue
第二个问题,
这是必然的,因为xiaohei没有type信息,根本无法进行创建.
不过,这个使我想到相
关的一些问题.
第三个问题, 字段的type不能这样写的,请参阅
http://code.google.com/p/nutz/wiki/ioc_hello
Original comment by wendal1985@gmail.com
on 1 Jun 2010 at 10:31
第一个问题相关的issue: http://code.google.com/p/nutz/issues/detail?id=94
Original comment by wendal1985@gmail.com
on 1 Jun 2010 at 10:32
第二个问题: 应该写成:
friend : {
refer : 'xiabai:nutz.ioc.demo.Pet'
}
Original comment by wendal1985@gmail.com
on 1 Jun 2010 at 10:43
如果用 {refer:'xxx'} 这里面不能再用 type
了,否则,就不能表示一个引用。
Original comment by zozoh...@gmail.com
on 1 Jun 2010 at 10:50
[deleted comment]
[deleted comment]
[deleted comment]
我试着运行了代码:
在目录: http://code.google.com/p/nutzdemo/source/browse/
POJO 代码 Pet.java:
/trunk/demo/hello_ioc/src/nutz/demo/ioc/book/Pet.java
IOC 配置文件 pets.js
/trunk/demo/hello_ioc/src/nutz/demo/ioc/book/pets.js
Main 函数:
/trunk/demo/hello_ioc/src/nutz/demo/ioc/book/HelloPet.java
运行结果:
2010-06-01 18:47:54,674 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get
'xiaobai'<class
nutz.demo.ioc.book.Pet>
2010-06-01 18:47:54,691 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Load
definition
2010-06-01 18:47:54,743 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...
2010-06-01 18:47:54,749 [main] DEBUG org.nutz.ioc.impl.ScopeContext - Save
object
'xiaobai' to [app]
XiaoBai - [Asia/Shanghai]
2010-06-01 18:47:55,628 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get
'xiaohei'<null>
2010-06-01 18:47:55,629 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Load
definition
2010-06-01 18:47:55,646 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...
2010-06-01 18:47:55,695 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get
'xiaobai'<null>
XiaoHei's friend is XiaoBai
2010-06-01 18:47:55,696 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get
'xiaohei'<null>
2010-06-01 18:47:55,696 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Load
definition
2010-06-01 18:47:55,696 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...
2010-06-01 18:47:55,698 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get
'xiaobai'<null>
2010-06-01 18:47:55,698 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get
'xiaohei'<null>
2010-06-01 18:47:55,698 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Load
definition
2010-06-01 18:47:55,699 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...
2010-06-01 18:47:55,699 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get
'xiaobai'<null>
false
Original comment by zozoh...@gmail.com
on 1 Jun 2010 at 11:04
现在明白了,相互引用只有在单例情况下才又意义。
Original comment by leu...@gmail.com
on 1 Jun 2010 at 12:17
friend : {
refer : 'xiabai:nutz.ioc.demo.Pet'
}
xiaobai后面的的类型nutz.ioc.demo.Pet,理想情况下应该可以根据��
�它信息推断出来的吧。呵
呵……我的要求高了,何况自己也没什么贡献,而且要求实��
�多了也会引入更多本可以避免的复杂度。
Original comment by leu...@gmail.com
on 1 Jun 2010 at 12:24
是可以推断出来的,我前面的回复已经说了,你可以仔细对��
�一下那三个文件
Original comment by zozoh...@gmail.com
on 1 Jun 2010 at 12:31
Original comment by wendal1985@gmail.com
on 25 Jun 2010 at 3:07
Original issue reported on code.google.com by
leu...@gmail.com
on 1 Jun 2010 at 9:11