Enable EagerSingletons using Managed and Guice Provider#70
Closed
mrserverless wants to merge 1 commit into
Closed
Conversation
…ernator or double injection.
|
@yunspace I'm following the basic concept behind using managed here, but I'm having a hard time wrapping my head around how I would leverage this to to provide an environment to a method in my Module class. For example, using the environment to provide a jersey client. Is this possibly using your managed approach? |
Member
|
Sorry for the lengthy delay. Since this PR was opened we have introduced dropwizard-guicier which creates the Guice injector during the run phase which solves the problems with eager singletons: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've added a test to demonstrate a potentially more elegant solution to the eager singleton issue, highlighted in #40, #31 and #19.
The steps are:
ManagedProviderfor all run-phase dependencies such asEnvironmentandConfigurationstartup()callProvider.get()This approach will avoid the initial performance hit cause by
@LazySingleton. Since all lazy loading is done during run-phase, not at the first request. Compared to double injection (#46) I think this has less impact on existing design and uses what's already available.