You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rules for @ProvidedBy and annotations don't need to be the same as for @ImplementedBy, where scoping conflicts could be problematic. For @ProvidedBy the scopes don't conflict.
isn't it an ordering thing? @ProvidedBy is a lazy load provider, singletons with providers need to be registered during module creation as a new provided class?
If you are going eager singleton even more so...
isn't it an ordering thing? @ProvidedBy is a lazy load provider, singletons with providers need to be registered during module creation as a new provided class?
If you are going eager singleton even more so...
You're right, maybe we need a new provided class to deal with this situation 👍
No I mean there are two types are singletons, -
But either way the outcome is the same, so you can't use @ProvidedBy for singletons..
this seems a very by design item.
No I mean there are two types are singletons, -
But either way the outcome is the same, so you can't use @ProvidedBy for singletons..
this seems a very by design item.
When we use @ProvidedBy, bind(Class1.class).in(Scopes.SINGLETON); is required to get singleton
When we use @Singleton, guice will create a singleton provider to give a singleton,
So if we both have @ProvidedBy and @Singleton, only @ProvidedBy is used by guice so we can't get singleton without ).in(Scopes.SINGLETON);
Activity
gissuebot commentedon Jul 7, 2014
From ori.schwartz on July 14, 2011 11:34:55
also for
@RequestScoped. i assume@ProvidedBy doesn't work with any scope annotations and always uses NO_SCOPE?a simple junit test is attached.
Attachment: gist
ProvidedByScopeTest.java
gissuebot commentedon Jul 7, 2014
From Ben.Manes on September 17, 2013 14:00:22
Any chance this is fixed in Guice 4.0? Just ran into this for a servlet filter.
birdmanmandbir commentedon Apr 27, 2020
It is still not fixed. I think it is because
@Providedbyhave larger priority than@Singleton?GedMarc commentedon Apr 27, 2020
isn't it an ordering thing?
@ProvidedByis a lazy load provider, singletons with providers need to be registered during module creation as a new provided class?If you are going eager singleton even more so...
birdmanmandbir commentedon Apr 27, 2020
You're right, maybe we need a new provided class to deal with this situation 👍
GedMarc commentedon Apr 27, 2020
No I mean there are two types are singletons, -
But either way the outcome is the same, so you can't use
@ProvidedByfor singletons..this seems a very by design item.
birdmanmandbir commentedon Apr 28, 2020
When we use
@ProvidedBy,bind(Class1.class).in(Scopes.SINGLETON);is required to get singletonWhen we use
@Singleton, guice will create a singleton provider to give a singleton,So if we both have
@ProvidedByand@Singleton, only@ProvidedByis used by guice so we can't get singleton without).in(Scopes.SINGLETON);Am I understanding it correctly?
And I also write more test cases:
ProvidedByScopeTest.zip
Fix bug (google#251)
Recognize scoping annotations on concrete types also annotated with @…