Why is GinModuleAdapter final ?

86 views
Skip to first unread message

David Nouls

unread,
Dec 16, 2011, 4:52:04 AM12/16/11
to googl...@googlegroups.com
Hi,
 
Is there a good reason to keep the GinModuleAdapter final ?
 
I'm struggling to get Gin/Guice code live together. I want to avoid code duplication between Guice and Gin modules.
 
I have some code that can be ran on both client and server and then I have some that is for GWT clients only. I can not declare the shared modules as a Guice module, since then GIN can not use it.
 
So I had defined GinModules for the shared components and wanted to use them with Guice through the GinModuleAdapter.
 
But, I am using annotations to supply the modules to my test code with a custom JUnit runner. But that requires a class literal.
So I need to be able to subclass the adapter class (and just call super( Module )) so that I can have a class literal.
 
Any ideas on how I can achieve this ? short from copying the GinmoduleAdapter class and removing the final ? For all I care you can make all the methods except the constructor final!
 
Would it be acceptable that GIN is modified to remove the final ?
 
David

Thomas Broyer

unread,
Dec 16, 2011, 2:29:08 PM12/16/11
to googl...@googlegroups.com
How about the following?

class FooGinModuleAdapter implements Module {
   @Override
   public void configure(Binder binder) {
      binder.install(new GinModuleAdapter(new FooGinModule()));
   }
}

David Nouls

unread,
Dec 20, 2011, 9:18:24 AM12/20/11
to googl...@googlegroups.com
Stupid me! :-D Thanks!

David Nouls

unread,
Feb 27, 2012, 9:39:07 AM2/27/12
to googl...@googlegroups.com
Hi,
 
I have a problem with the GinModuleAdapter class. When I install a Gin module in a Guice module that has a binding for an assisted inject, it seems to blow up as soon as I add the GinModuleAdapter.
 
I tried the exact same binding with a trunk build and that seems to have fixed the issue ... Now I am really wondering when we will get an updated GIN! I am not allowed to use a self-build version of GIN (corporate bs).
 
Here is the stack, maybe it rings a bell ?

INFO: An exception was caught and reported. Message: java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
       at java.util.AbstractCollection.add(AbstractCollection.java:221)
       at com.google.gwt.inject.rebind.adapter.BinderAdapter.install(BinderAdapter.java:59)
       at com.google.gwt.inject.client.AbstractGinModule.install(AbstractGinModule.java:55)
       at com.swift.editor.shared.SharedEditorModule.configure(SharedEditorModule.java:73)
       at com.google.gwt.inject.client.AbstractGinModule.configure(AbstractGinModule.java:33)
       at com.google.gwt.inject.rebind.adapter.GinModuleAdapter.configure(GinModuleAdapter.java:49)
       at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
       at com.google.inject.AbstractModule.install(AbstractModule.java:118)
       at com.swift.sawa.messenger.MessengerEJBModule.xml(MessengerEJBModule.java:224)
       at com.swift.sawa.messenger.MessengerEJBModule.configure(MessengerEJBModule.java:186)
       at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
       at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
       at com.google.inject.spi.Elements.getElements(Elements.java:101)
       at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
       at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
       at com.google.inject.Guice.createInjector(Guice.java:95)
       at com.google.inject.Guice.createInjector(Guice.java:72)
       at com.google.inject.Guice.createInjector(Guice.java:62)

On Tuesday, December 20, 2011 3:18:24 PM UTC+1, David Nouls wrote:
Stupid me! :-D Thanks!
Reply all
Reply to author
Forward
0 new messages