--
You received this message because you are subscribed to the Google Groups "GWT-Ent Developer Forum" group.
To post to this group, send email to gwt...@googlegroups.com.
To unsubscribe from this group, send email to gwt-ent+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwt-ent?hl=en.
if("aa.bbb.Class1".equals(className)){
return GWT.create(aa.bbb.Class1);
}
else if("aa.bbb.Class2".equals(className)){
return GWT.create(aa.bbb.Class2);
}
....
这样,虽然在编译的时候没有节省时间,但是在开发模式的时候,因为只会生成指定类的代码,
不会生成没有用到的代码,能节省一部分时间。因为我们发现,在使用gwt开发的时候,
很不好的一点就是dev mode太慢了,刷新一下页面要等好久,尤其是界面,没有可视化编辑器,每次修改了界面,
改了点代码,一刷新就等待半分钟才能看到效果,界面开发效率就很慢了。
如果再长时间的话,开发人员就更无法忍受了。
c)我的一点想法:relationTypes 好像实际用处不大,反而把整个结构搞的很复杂。
我可以使用google talk,我的邮件是sunxuf...@gmail.com
--
You received this message because you are subscribed to the Google Groups "GWT-Ent Developer Forum" group.
To post to this group, send email to gwt...@googlegroups.com.
To unsubscribe from this group, send email to gwt-ent+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwt-ent?hl=en.
>2B) 更加重要的是把GWT.create这样子很重要的操作给占用了,比如你写了一个你的生成器也要操作这个类,可是你发现这个宝贵的资源被Reflection给占用了
这个我倒是没考虑过,多谢您的提醒,以后再作设计的时候我们也会考虑这一点的。
现在的 Deferred binding,我们看到的大概有3种模式
1.类继承接口(比如说标注接口DynaClass),
然后GWT.create(DynaClass的子类),
generate定义为
<generate-with ...>
<when-type-assignable class="DynaClass" />
</generate-with>
我之前说的就是这种方式
2.在jsonizer中看到的用法
比如说有一个对象叫Person,如果想生成关于Person的操作的类
那么就定一个接口 PersonJsonizer,放在同样的包下面,
这个接口是一个标注接口,
他从 Jsonizer 继承,主要用于Deferred binding识别
generate定义为
<generate-with ...>
<when-type-assignable class="Jsonizer" />
</generate-with>
然后GWT.create(PersonJsonizer)
这样,他就不需要改变原有的类,只需要在相同的包下面放一个
PersonJsonizer接口就可以了
3.在gwt2.0 ui binder中看到的用法
interface Binder extends UiBinder<Widget, Contacts> { }
private static final Binder binder = GWT.create(Binder.class);
通过泛形,在gerator中可以拿到那个类的泛形信息,从而可以生成对应的类
具体可以看他自带的例子
不知道我表达清楚了没有
后面两种方式,都可以在不改变原有类的基础上,实现Deferred binding
这样,我们使用第一种方式,结合后面两种,就基本可以解决
"你写了一个你的生成器也要操作这个类,可是你发现这个宝贵的资源被Reflection给占用了"
的问题
> 2A) 我也很想生成多个类,准备把这个改动放在这次重构里, 但是我现在还不知道要怎么样在一个生成器里生成多个类, 囧
一个生成器里生成多个类,我也没试过,不过一直以为,只要用他的那几个api,
应该和生成一个类没什么区别吧,找时间我试一下.
不过我说的和生成多个类没什么关系,
可能我之前没有说清楚,我之前说的是有2个generator
第1个generator,
使用一个标注接口 DynaClass 来标注某个类是可以反射的
使用GWT.create(DynaClass的子类) 来得到一个 ClassType对象,
从而可以使用ClassType进行反射操作
这个是和domain类对应的
第2个generator,
就是类似现在的TypeOracle的 Generator,
生成的java代码,也就是现在的 TypeOracle_Visitor ,
我们可以将它生成为如下的样子
if("aa.bbb.Class1".equals(className)){
//使用第1个generator
return GWT.create(aa.bbb.Class1);
}
else if("aa.bbb.Class2".equals(className)){
//使用第1个generator
return GWT.create(aa.bbb.Class2);
}
....
第2个generator,是一个总体的 generator,会枚举所有的类,
生成很多if语句
这种方式,不涉及到一个generator中,生成很多类的情况.
这种方式很重要,
因为在开发模式的时候,只会生成指定类的代码,
不会生成没有用到的代码,在类多的时候,能节省大量的时间。
另外,您提到的 GWT新提供的JavaScript延迟加载功能,
我上网搜了一下,都是在说Deferred binding,不知道您说的是不是这个.
或者能给我发个链接,我也学习一下
祝周末愉快
--
You received this message because you are subscribed to the Google Groups "GWT-Ent Developer Forum" group.
To post to this group, send email to gwt...@googlegroups.com.
To unsubscribe from this group, send email to gwt-ent+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwt-ent?hl=en.
private interface ClassType_aa_bbb extends ClassType<aa.bbb>{}
if("aa.bbb.Class1".equals(className)){
//使用第1个generator
return GWT.create(ClassType_aa_bbb.class);
}
3.然后,再写一个generator,生成每个类独立的代码,存放于类相同的包下面,对应上面的
return GWT.create(ClassType_aa_bbb.class);
还有,是不是可以加上直接存取属性的功能呢。
如果这两点满足的话,我们就可以直接使用这个项目了,就不用自己写了。
如果可以的话,我可以帮助实现这两个功能。
因为我们也急着用,呵呵
--
You received this message because you are subscribed to the Google Groups "GWT-Ent Developer Forum" group.
To post to this group, send email to gwt...@googlegroups.com.
To unsubscribe from this group, send email to gwt-ent+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwt-ent?hl=en.
还有您昨天说的code splitting,我大概看了一下,它也是异步的,所以,如果您以后要加的话,是不是
TypeOracle的
public ClassType getClassType(String name);
要改成 void getClassType(String name,AsyncCallback callback);
这样会影响到用户接口,是不是要提早作打算啊。
--
You received this message because you are subscribed to the Google Groups "GWT-Ent Developer Forum" group.
To post to this group, send email to gwt...@googlegroups.com.
To unsubscribe from this group, send email to gwt-ent+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwt-ent?hl=en.