Java Reference
In-Depth Information
5
WHAT'S IN THIS CHAPTER?
Introduction to dependency injection
Why DI is important in Java EE
How to implement DI in plain code
How DI is implemented in Java EE
Introduction to Content Dependency Injection
Key differences between CDI and EJB containers
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code download for this chapter is found at www.wrox.com/go/
projavaeedesignpatterns on the Download Code tab. The code is in the Chapter 05
download and individually named according to the names throughout the chapter.
Dependency injection (DI) is one of the few well‐known and accepted design patterns that
was not listed in the topic by the Gang of Four.
1 Today, it has been used widely in modern
programming languages both internally and as a best practice to promote loose coupling.
J2EE was designed to handle the most complex systems but failed miserably by
overcomplicating the development of even the simpler systems. The original design of
J2EE relied on heavyweight complexity and tight coupling, which led to the popularity of
frameworks such as Spring and Pico container. In 2004, Martin Fowler published an article
on the inversion of control containers and the dependency of the injection pattern. 2 Most
vendors did not support and encourage developers to use the J2EE container. However,
soon the lightweight containers took over, they became ofi cially supported and, even more,
Spring became the unofi cial de facto standard and led to the redesign of Enterprise Java from
scratch.
 
Search WWH ::




Custom Search