Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding generated classes in gin
    text
    copied!<p>I am trying to dynamically generate some set of event handlers (using <code>com.google.gwt.core.ext.Generator</code> subclass). The whole generation process works fine, my generated handlers accepts EventBus via setter injection (@Inject annotation) and the whole idea is that these automagically generated handlers register themselves in the (injected) EventBus under the hood. The problem is that all these handlers must be somehow instantiated. GIN does not know anything about them until they will be bound in GIN module; something like below:</p> <pre><code>bind(MyDynamicallyGeneratedHandler.class).asEagerSingleton(); </code></pre> <p>The problem with this code is that I have to generate gin module also (which will contain all bind(...) instructions). It works well but I cannot install generated module (@Inject it) into another not generated module so that its bind instructions are executed (as a result of install(MyDynamicModule.class)). I tried dirty tricks with static injection and providers - all without success. </p> <p>Is there any way to configure dynamically generated GIN module? Or maybe is there any way to instantiate dynamically generated handlers so that setter injection (and thus event bus registration) happens? </p> <p>Here is sample code snippet:</p> <pre><code>// it is standard interface public interace DynamicHandler { @Inject void setEventBus(EventBus eventBus); } // one of dynamically generated handlers // where (how) to instantiate me? public class MyHandler implements DynamicHandler { @Inject AnotherHandlerSpecificComponent component void setEventBus(EventBus eventBus) { eventBus.register(...); // register myself } } </code></pre> <p>Important thing to note is that all these dynamically generated handlers have some other dependencies @Injected (apart from EventBus). And these dependencies (their types) ale handler-specific (<code>AnotherHandlerSpecificComponent</code> in the example above). So what I need to do is to instantiate these handlers in a way that triggers GIN injection (I cannot, for example, inject dependencies manually).</p> <p>Thanks in advance for any clues. I am totally stucked...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload