This post has also been published on the blog site of my current employer. You can access it here.
The following post talks about my first brush with Guice based on a couple of hours that I spent on it for the past few days. I would not get into burning fire of comparing Guice with Spring as there has already been a lot of debate on that. Personally in my view it is comparing apple with oranges. We can probably just make comparison between how DI works on Spring and how it works on Guice but then we know that Spring is much more than DI, it is a feature full comprehensive stack.
So not getting into that path any further back to DI with Guice.
Guice wholly embraces annotations and generics. The idea is that annotations finally free you from error-prone, refactoring-adverse string identifiers and frees you up from the XML configuration hell. Guice injects constructors, fields and methods (any methods with any number of arguments, not just setters)
The injection process for Guice is a two step injection process.
1.Define the Bindings.
2.Inject the concrete implementations at the right places.
Let us look at how it is done…





