A comparative look at three popular dependency injection frameworks: Spring, Guice, and OSGi declarative services.
Supporting code is found at https://github.com/rombert/email-sender .
10. Dependency Injection – walkthrough
Email Sender App
Technologies
Deliver formatted email
to large number of
recipients
Spring 3.2 - JavaConfig
http://robert.muntea.nu
Guice 3.0
OSGi DS 1.6.2
@rombert
11. Dependency Injection – bottom line
All frameworks prevent accidental complexity
•
Different binding approaches
•
•
Spring binds beans
•
Guice and OSGi bind services to consumers
Different approaches to run-time composition
•
•
Spring and Guice have a static view of the world
•
OSGi is dynamic by definition
•
Which view is right for you?
http://robert.muntea.nu
@rombert
12. Dependency Injection – bottom line
Different approaches to scopes
•
•
Spring and OSGi default to singleton
•
Guice defaults to instance
Different approaches to instantation
•
•
Spring and Guice default to eager
•
OSGi (SCR) defaults to lazy
http://robert.muntea.nu
@rombert