I don't know how many different Providers you are creating, but
wrapping, or using @Provides could get tedious.

How about having two separate implementations of com.foo.Provider, one
that implements com.google.inject.Provider and one that doesn't and
just ship different jars?

-Dave

On Thu, Apr 23, 2009 at 11:20 AM, Adrian Cole <[email protected]> wrote:
> Thanks, Logan..  I had the same wrapping idea as I walked back to computer.
>
> This will work!
> Cheers,
> -Adrian
>
> On Thu, Apr 23, 2009 at 5:18 PM, Logan Johnson <[email protected]>
> wrote:
>>
>> It depends on the purpose of exposing Provider.  If you are exposing your
>> own Provider implementations, just make them implement guice's interface
>> (for internal use) and an identical interface of your own (for exposure to
>> the component's clients).
>> public interface com.foo.Provider<T> {
>>     T get();
>> }
>> class MyProvider<T> implements com.foo.Provider<T>,
>> com.google.inject.Provider<T> {
>>     T get();
>> }
>> If you are exposing arbitrary Providers created by Guice, wrap them in
>> your own interface.
>>
>> final class MyProvider<T> implements com.foo.Provider<T> {
>>      MyProvider(com.google.inject.Provider<T> guiceProvider) { ... }
>>      T get() {
>>         return guiceProvider.get();
>>      }
>> }
>> You can do a similar wrapping if you're accepting Providers from the
>> client.
>>
>> On Thu, Apr 23, 2009 at 11:00 AM, Adrian Cole <[email protected]> wrote:
>>>
>>> Perhaps...  Although if my api interface extends a guice one, I may as
>>> well have used the guice one, right?  The user would still need guice
>>> libraries loaded or the IDE would turn somewhat red.  Other alternates might
>>> include putting the guice Provider interface into my api jar.  However, I'd
>>> like to avoid exposing guice in my external apis.
>>> Thanks for the response...  I do appreciate it.  Do you have any other
>>> ideas?
>>> -Adrian
>>>
>>> On Thu, Apr 23, 2009 at 4:45 PM, Adam Ruggles <[email protected]>
>>> wrote:
>>>>
>>>> Couldn't you make your provider interface extend the Guice one?
>>>>
>>>> On Thu, Apr 23, 2009 at 7:07 AM, AdrianCole <[email protected]> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I'd like to minimize the compile-time dependency of guice on an
>>>>> application who wants to use my guiced component.
>>>>>
>>>>> I'd like to provide a method:
>>>>>
>>>>> Provider<Foo> void getFooProvider()
>>>>>
>>>>> Difference is that I'd like to use the interface com.foo.Provider as
>>>>> opposed to the guice one.
>>>>>
>>>>> Is there a way to make this happen?
>>>>>
>>>>> Thanks,
>>>>> -Adrian
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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