With EJB 3, dependency injection has greatly simplified accessing EJB, JPA Entity Manager, resources such as JDBC DataSource and JMS Objects, and services such as Timer, User Transaction, and Web Services. The 'Dependency Injection in EJB 3' Refcard, written by Debu Panda, is useful for those building enterprise Java applications with EJB 3 and JPA. It lists all metadata annotations, describes them with examples and also provides descriptions for XML elements that you can use for injection. Download Dependency Injection in EJB 3 here (Note: You'll need to fill out a short registration form prior to downloading the Refcard)
- Posted by: Nate Borg
- Posted on: June 02 2008 10:03 EDT
- Seriously, why DI? by Casual Visitor on June 06 2008 17:18 EDT
- Re: The Definitive Guide to Dependency Injection in EJB 3 by Krishna Srinivasan on February 20 2009 19:52 EST
So, DI lets me combine data access 'Singletons' with business logic 'Singletons' at runtime via a (usually) verbose configuration mechanism (XML, Annotations). But what are the real benefits of those multiple levels of indirection? Better testability is an often repeated argument. But even DI aficionados don't use DI for tests but test objects in isolation using mock-objects. Why introduce more complexity (yes, DI enhances complexity, contrary to popular belief) into the application when you can just 'parameterize from the top' (http://accu.org/index.php/journals/1411)? And what's so great with designs that mainly consist of 'Singletons' and JavaBeans/DTOs anyway?