I have a mobule file with:
<extend-configuration-property name="gin.ginjector.extensions" value="test.client.gin.ClientInjectorAdditional"/>
My ClientInjectorAdditional is:
public interface ClientInjectorAdditional extends Ginjector {
NotificationFetcher getNotificationFetcher();
}
Now I want to inject NotificationFetcher in my entry point class. I tried
public class Test implements EntryPoint {
private static final ApplicationController controller = GWT.create(ApplicationController.class);
@Inject
private NotificationFetcher notificationFetcher;
@Override
public void onModuleLoad() {
controller.init(;
...
}
}
The problem is that notificationFetcher is not injected.
How do I use GWTP with ginjector extensions?
Edit:
When I use
private final ClientInjectorAdditional injector = GWT.create(ClientInjectorAdditional.class);
I get the following warning:
No gin modules are annotated on Ginjector interface test.client.gin.ClientInjectorAdditional, did you forget the @GinModules annotation?
Edit:
I tried:
@GinModules({ ClientModule.class }) public interface ClientInjectorAdditional extends Ginjector { ... }
But this gives the following error:
[DEBUG] [test] - Rebinding test.client.gin.ClientInjectorAdditional
[DEBUG] [test] - Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
[ERROR] [test] - Error injecting com.gwtplatform.dispatch.rest.client.ActionMetadataProvider: Unable to create or inherit binding: No @Inject or default constructor found for com.gwtplatform.dispatch.rest.client.ActionMetadataProvider
Path to required node:
com.gwtplatform.dispatch.rest.client.RestRequestBuilderFactory [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:99)]
-> com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:99)]
-> com.gwtplatform.dispatch.rest.client.ActionMetadataProvider [@Inject constructor of com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory]
[ERROR] [test] - Error injecting com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider: Unable to create or inherit binding: No @Inject or default constructor found for com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider
Path to required node:
com.gwtplatform.dispatch.rest.client.serialization.Serialization [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:103)]
-> com.gwtplatform.dispatch.rest.client.serialization.JsonSerialization [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:103)]
-> com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider [@Inject constructor of com.gwtplatform.dispatch.rest.client.serialization.JsonSerialization]
[ERROR] [test] - Deferred binding failed for 'test.client.gin.ClientInjectorAdditional'; expect subsequent failures
[ERROR] [test] - Failed to create an instance of 'test.client.test' via deferred binding
[ERROR] [test] - Unable to load module entry point class test.client.test (see associated exception for details)
[ERROR] [test] - Failed to load module 'test' from user agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' at http-server.fritz.box:61196
GWTP creates the ginjector automagically with all its presenters and views getters. it also supports extending this ginjector for non GWTP objects. here's how you do it:
a. define an interface, lets name it GinjectorExtensions in package some.package.client
package some.package.client;
public interface GinjectorExtensions {
//your objects here
MyConstants getMyConstants();
MyMessages MyMessages();
MyRequestFactory getRequestFactory();
}
b. Edit your GWT module xml file to include the following line (which tells GWTP to add your lines of code to it's autogen Ginjector):
<set-configuration-property name="gin.ginjector.extensions"
value="some.package.client.GinjectorExtensions"/>
Then you just @Inject your objects anywhere and everything should work as expected.
EDIT: after reviewing your code, just remove the "extends Ginjector" from ClientInjectorAdditional and everything should work.