lishunli / nutz

Automatically exported from code.google.com/p/nutz
0 stars 0 forks source link

简化json配置(在ioc配置的是时候能把包名用变量代替?) #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
现在的ioc配置中类只支持写全名,例如:
var ioc = {
    pets : {
        type : "org.nutz.demo.PetService",
        args : [ {
            refer : "dao"
        } ]
    },
    masters : {
        type : "org.nutz.demo.MasterService",
        args : [ {
            refer : "dao"
        } ]
    },
        ......
}
能否把包名用变量或占位符代替?例如:
var ioc = {
    package:"com.godpen.demo.",
    pets : {
        type : package+"PetService",
        args : [ {
            refer : "dao"
        } ]
    },
    masters : {
        type : package+"MasterService",
        args : [ {
            refer : "dao"
        } ]
    },
        ......
}
这样看上去更简洁。

Original issue reported on code.google.com by oeqe.com@gmail.com on 7 Dec 2009 at 7:28

GoogleCodeExporter commented 9 years ago
占位符,我想不止是可以支持 type, events 和 parent 
都应该支持。
在 MapLoader 中做修改即可。
支持一个特殊变量: $vars
{
   $vars : {
       v1 : "XXXXX",
       v2 : "XXXXXX",
       ...
   }
}
MapLoader 先解析一下这个变量,然后替换所有的 type, events 和 
parent

Original comment by zozoh...@gmail.com on 7 Dec 2009 at 7:35

GoogleCodeExporter commented 9 years ago
我觉得没有必要. 这样反而增加学习曲线和排错的难度.
使用完全限定名, 是最直观明了的.

Original comment by wendal1985@gmail.com on 7 Dec 2009 at 7:42

GoogleCodeExporter commented 9 years ago
我觉得没有必要. 这样反而增加学习曲线和排错的难度.
使用完全限定名, 是最直观明了的.

Original comment by wendal1985@gmail.com on 7 Dec 2009 at 7:44

GoogleCodeExporter commented 9 years ago
fixed in 1.a.24

Test case: AdvanceJsonIocTest.test_vars

变量只能存在在 type, events, parent, 
以及字符串型的值中,即使用变量时 ${XXX} 必须用引号包裹:
 'TTT${XXX}TTT'
或
 "TTT${XXX}TTT"

Original comment by zozoh...@gmail.com on 15 Dec 2009 at 10:35

GoogleCodeExporter commented 9 years ago

Original comment by zozoh...@gmail.com on 28 Dec 2009 at 7:32

GoogleCodeExporter commented 9 years ago

Original comment by lhasa...@gmail.com on 15 Mar 2010 at 7:07

GoogleCodeExporter commented 9 years ago

Original comment by wendal1985@gmail.com on 13 May 2010 at 10:53