Status: New
Owner: ----

New issue 590 by [email protected]: Better error reports for Assistedinject where source class is not an interface
http://code.google.com/p/google-guice/issues/detail?id=590

I recently attempted something which I think turns out not to be supported by assisted injection. However, the error report was fairly obscure and could have been clearer.

I was attempting to inject a ServletContextHandler differently in different modules, using FactoryBuilder to dynamically provision factories for subclasses of ServletContextHandler. These subclasses offered constructors annotated with @Assisted, and the correct parameters were available in the Factory interface definition.

However it turns out that org.eclipse.jetty.servlet ServletContextHandler is a concrete superclass and not an interface.

However, rather than complaining that ServletContextHandler is not an interface, Guice warned me that no appropriate constructor could be found. I therefore spent quite some time trying to ensure the constructor was properly visible and trying many combinations to satisfy the injector. However, the Injector could tell immediately that the source class was not an interface.

Reading the documentation I finally I came to the conclusion that FactoryBuilder is unable to dynamically provision a factory unless the return value satisfies the signature of an interface, but if this was warned right from the beginning it would be helpful.

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to