Difference between @Singleton and .asEagerSingleton()
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
Hello,
I have a project where I see my service is failing to initialise.
I am using dropwizard guicey - but it uses Guice underneath, and my question is specific for Guice because the dependency injection is the theme here.
I am attaching the project in question. So that the issue can be reproduced and seen.
The class - `TheProblemClass` extends `AbstractScheduledService` (Guava) and implements `Managed` interface in Dropwizard.
The idea is that I ought to be able to start/stop the service upon Main server startup and shutdown respectively. Also, I could schedule a periodic call to one of its methods.
Some things I have noticed.
1. When `TheProblemClass` is annotated with `@Singleton` - it is working fine
2. When `TheProblemClass` is NOT annotated with `@Singleton` - it is always hanging.
In my Module - I have bound it as an eager singleton. My understanding was that I only needed to do this in one place. And the rest should be OK. Have I misunderstood how Singleton Annotation and Module Configs are supposed to be working together?
[Archive.zip](https://github.com/user-attachments/files/17194985/Archive.zip)
Contributor guide
Assessment
This issue has not been assessed yet.