question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

provider methods can't bind eager singletons

See original GitHub issue

From medotin on June 25, 2008 09:39:59

We need an @Eager or something for provider methods.

_Original issue: http://code.google.com/p/google-guice/issues/detail?id=216_

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:7
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
yaitskovcommented, Oct 5, 2017

use spring 😉

0reactions
samebcommented, Jan 11, 2019

Folks, please be kind to each other.

As for the question at hand, there’s no built-in to do what you want exactly. You can workaround the problem by introducing an @EagerSingleton annotation, having it delegate to Singleton scope, and manually iterating through bindings in the injector and eagerly instantiating bindings that are eager singletons.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Binding @Provides method as eager singleton - Stack Overflow
In the bug report you linked, "provider methods" means "methods annotated with @Provides". So you're right, it's not directly possible. But ...
Read more >
Re: Issue 216 in google-guice: provider methods can't bind eager ...
Comment #10 on issue 216 by joshbb...@gmail.com: provider methods can't bind eager singletons http://code.google.com/p/google-guice/issues/detail?id=216 Why ...
Read more >
Dagger - Square Open Source
Classes that lack @Inject annotations cannot be constructed by Dagger. ... Annotate an @Provides method or injectable class with @Singleton .
Read more >
Eager singletons - Java 9 Dependency Injection [Book] - O'Reilly
Eager singletons Guice provides special syntax for making an object that has the singleton scope, and is initialized to eager mode rather than...
Read more >
How to bind one implementation to multiple interfaces?
To be clear, do I need to use the Provider approach if I want a single ... bind to both (and not one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found