The Definitive Guide to Dependency Injection in EJB 3


News: The Definitive Guide to Dependency Injection in EJB 3

  1. 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)
  2. Seriously, why DI?[ Go to top ]

    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' ( And what's so great with designs that mainly consist of 'Singletons' and JavaBeans/DTOs anyway?