Just want to pull this error message out:

 Binding to core guice framework type is not allowed: Provider.

I imagine that this is a relatively large first-timer problem with
Guice.  Perhaps the error message should offer the solution in this
case, since it's well-known?  Either way, I would recommend revising
the wording (if it stands) to something like, "Binding to Provider is
not allowed. (It is a core guice framework type.)"  Appending it at
the end doesn't flow well in my head.

Sam

On Mon, Oct 20, 2008 at 7:04 AM, Andrew Clegg <[EMAIL PROTECTED]> wrote:
>
> Morning folks,
>
> I have a custom provider for creating SoapDispatchHandler objects,
> which implement an interface called DispatchHandler.
>
> I want to set up a binding in my module such that any reference to
> Provider<DispatchHandler> is injected with an instance of
> SoapDispatchHandlerProvider, the provider class which builds and
> returns SoapDispatchHandler objects. (Needless to say,
> SoapDispatchHandlerProvider implements Provider<DispatchHandler>.)
>
> I originally did it like this:
>
> bind( new TypeLiteral<Provider<DispatchHandler>>(){} )
> .to( SoapDispatchHandlerProvider.class );
>
> but this gives me an error:
>
>  Binding to core guice framework type is not allowed: Provider.
>
> So to work around it I created an empty interface like so:
>
> public interface DispatchHandlerProvider extends Provider<DispatchHandler> {}
>
> and then made SoapDispatchHandlerProvider implement
> DispatchHandlerProvider instead of directly implementing
> Provider<DispatchHandler>. This works; I can go:
>
> bind( DispatchHandlerProvider.class ).to( SoapDispatchHandlerProvider.class );
>
> without any problems. But I can't help feeling empty interfaces smell
> a bit funny. Is this the right way to approach this scenario?
>
> Thanks!
>
> Andrew.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to