Why is GinModuleAdapter final ?

已查看 86 次
跳至第一个未读帖子

David Nouls

未读,
2011年12月16日 04:52:042011/12/16
收件人 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

未读,
2011年12月16日 14:29:082011/12/16
收件人 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

未读,
2011年12月20日 09:18:242011/12/20
收件人 googl...@googlegroups.com
Stupid me! :-D Thanks!

David Nouls

未读,
2012年2月27日 09:39:072012/2/27
收件人 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!
回复全部
回复作者
转发
0 个新帖子