I don't think you shuld be conserning yourself with binding provider
directly.

bind(DispatchHandler.class).toProvider(SoapDispatchHandlerProvider.class);

now if you do

@Inject
Provider<DispatchHandler> handler;

Guice will use SoapDispatchHandlerProvider. Hope it helps.

Cheers,
Alen

On 20 okt., 13:04, "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