Adam Bien's Weblog
Contexts and Dependency Injection in Java EE 6 - Free Article
Contexts and Dependency Injection in Java EE 6 article is online. I get many questions regarding the differences between EJB 3.X and CDI especially regarding the Contexts (the C in CDI). The EJB "vs." CDI issue became the focus of this article. Feedback, as always, is highly appreciated!
Posted at 02:40PM Apr 12, 2011 by Adam Bien in Real World Java EE Patterns - Rethinking Best Practices | Comments[2] | Views/Hits: 56646
NEW Workshop: "JPA, NoSQL, Caching, Grids and Distributed Caches with Java EE 7", May 7th, 2013, Airport Munich
A book about rethinking Java EE Patterns
Tweet Follow @AdamBien

Hi Adam, not sure if I get it right.
1)
Can the EJBs be annotated with CDI annotations for example @Qualifier - to resolve required implementation of an interface?
2)
Is there any difference in an EJB injecting another EJB using @EJB and @Inject?
Example:
@Stateless
public class EJB1 {
//1)
@EJB private EJB2 ref2a;
@Inject private EJB2 ref2b; //is this equivalent as ref2a?
//2)
//is this possible?
@EJB @Ingredient(A) Ingredient ejb3a;
@EJB @Ingredient(B) Ingredient ejb3b;
@Inject @Any Instance<Ingredient> ingredients;
...
}
@Stateless
public class EJB2 {
...
}
@Stateless @Ingredient(A)
public class EJB3a implements Ingredient {
...
}
@Stateless @Ingredient(B)
public class EJB3b implements Ingredient {
...
}
Thanks for article.
Posted by cody on April 16, 2011 at 09:08 PM CEST #
Adam: excellent article. Not to give you a big head, but many more of your thoughts need to be published on java.net or java.dzone.com!
I have a question though... Is there any sort of JEE provided api for AOP(Interceptors) JSF managed beans?
In JSF, I'd like to be able to use "@EJB SomeService serviceHandle", but wrap it with a special security, tracking, or other interceptor.
Posted by Jon on April 22, 2011 at 04:46 PM CEST #