【发布时间】:2012-03-05 06:16:03
【问题描述】:
我正在尝试在 MVP GWT 2.4 中使用 Gin。在我的模块中,我有:
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
@Override
protected void configure() {
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
...
}
上面的代码使用了新的com.google.web.bindery.event.shared.EventBus。当我想在实现 Activity 的 MVP 活动中注入事件总线时,问题就来了:
package com.google.gwt.activity.shared;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
public interface Activity {
...
void start(AcceptsOneWidget panel, EventBus eventBus);
}
Activity 使用已弃用的com.google.gwt.event.shared.EventBus。我怎样才能调和两者?显然,如果我要求使用已弃用的 EventBus 类型,那么 Gin 会抱怨,因为我没有为它指定绑定。
更新:这将允许应用程序构建,但现在有两个不同的EventBuss,这太糟糕了:
protected void configure() {
bind(com.google.gwt.event.shared.EventBus.class).to(
com.google.gwt.event.shared.SimpleEventBus.class).in(Singleton.class);
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
...
【问题讨论】:
-
一个技巧是在我的代码中随处使用已弃用的版本。这样做有多糟糕?
标签: java gwt mvp gwt-gin event-bus