user1768830
user1768830

Reputation:

GWT GIN Provider compile error

I am trying to configure my GIN module to bind ActivityManager requests to a DefaultActivityManagerProvider:

import com.google.inject.Provider;

public class DefaultActivityManagerProvider implements Provider<ActivityManager> {
    @Override
    public ActivityManager get() {
        return new ActivityManager(new MyDefaultActivityMapper());
    }
}

But when I go to actually bind it:

public class MyAppGinModule extends AbstractGinModule {
    @Override
    protected void configure() {
        bind(ActivityManager.class).toProvider(DefaultActivityManagerProvider.class);
    }
}

I get a compile error on the bind(...) statement:

Bound mismatch: The generic method toProvider(Class<I>) of type
GinLinkedBindingBuilder<T> is not applicable for the arguments
(Class<DefaultActivityManagerProvider>). The inferred type
DefaultActivityManagerProvider is not a valid substitute for the
bounded parameter <I extends Provider<? extends ActivityManager>>

What am I doing wrong here?!? I have followed countless examples such as this one and can't figure out why I am getting the error! Thanks in advance!

Upvotes: 2

Views: 879

Answers (1)

Rebzie
Rebzie

Reputation: 310

toProvider is not properly supported

http://code.google.com/p/google-gin/wiki/GinFaq

http://code.google.com/p/google-gin/wiki/GuiceCompatibility

The provider need to be public static

static class DefaultActivityManagerProvider implements Provider<ActivityManager> {
    @Override
    public ActivityManager get() {
        return new ActivityManager(new MyDefaultActivityMapper());
    }
}

Upvotes: 3

Related Questions