Usage
We often use GWT Generator classes in GWT to construct classes for us during compile time. However if you are using the Dependency Injection library GIN, it will not call the Generator that you have specified in your gwt.xml settings.
GinJitsu allows you to use GWT Generators inside your GIN injected classes. It also implements an @AfterInject
to indicate a method that should be called after all the class members have been injected.
In your project, add this to your project's pom.xml
or otherwise manually add the jar to your classpath if you do not have maven.
<repositories>
<repository>
<id>bintray-gammagec-maven</id>
<url>http://dl.bintray.com/gammagec/maven</url>
</repository>
</repositories>
<dependency>
<groupId>com.chrisgammage</groupId>
<artifactId>GinJitsu</artifactId>
<version>1.0</version>
</depenency>
Inside your Gwt Project's MyProject.gwt.xml
add the following
<inherits name='com.chrisgammage.ginjitsu.GinJitsu'/>
In GIN you will normally extend Ginjector for your Injector class. In GinJitsu you should use the JitsuInjector instead.
By using JitsuInjector, you should now be able to use the @AfterInject
method annotation inside injected classes to indicate the method should be called after member variable are injected.
In order to make an injected class use a GWT Generator you have to add the @GinExtensions
annotation to your JitsuInjector class. Here is an example from the test case which is included in the project.
@GinExtensions({ @GinExtension(clazz = TestObjectImpl.class,
generator = TestGenerator.class),
@GinExtension(clazz = AssistedObjImpl.class,
generator = TestGenerator.class)})
@GinModules(TestModule.class)
public interface TestInjector extends JitsuInjector {
...
Now whenever a TestObjectImpl instance is injected, the GWT Generator TestGenerator will be used to generate the class.