2011-10-30 12 views
5

GIN Modulo:GWT GIN - banale caso d'uso non riesce (EventBus)

public class InjectorModule extends AbstractGinModule { 
    @Override 
    protected void configure() { 
     bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); 
    } 
} 

iniettore:

@GinModules(InjectorModule.class) 
public interface Injector extends Ginjector { 
    EventBus getEventBus(); 
} 

GWT punto di ingresso Modulo:

public class Module1 implements EntryPoint { 
    private final Injector injector = GWT.create(Injector.class); 

    public void onModuleLoad() {   
     injector.getEventBus(); 
    } 
} 

Rimozione chiamata a injector.getEventBus() make tutto funziona bene Chiamata a injector.getEventBus() cause:

Caused by: java.lang.RuntimeException: Deferred binding failed for 'com.google.web.bindery.event.shared.EventBus' (did you forget to inherit a required module?) 
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53) 
at com.google.gwt.core.client.GWT.create(GWT.java:97) 
at com.XXX.app.client.InjectorImpl.create_Key$type$com$google$web$bindery$event$shared$EventBus$_annotation$$none$$(InjectorImpl.java:72) 
at com.XXX.app.client.InjectorImpl.get_Key$type$com$google$web$bindery$event$shared$EventBus$_annotation$$none$$(InjectorImpl.java:86) 
at com.XXX.app.client.InjectorImpl.getEventBus(InjectorImpl.java:7) 
at com.XXX.app.client.Module1.onModuleLoad(Module1.java:24) 

Modalità di sviluppo GWT dice:

23:58:50.287 [ERROR] Deferred binding result type 'com.google.web.bindery.event.shared.EventBus' should not be abstract 

risposta

7

se si sta utilizzando GWT 2.4:

Ora ci sono due EventBus (uno è deprecato) assicurarsi che si sta utilizzando lo stesso tipo nel injetor e nel tuo entrypoint.