• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why EJB injection is not available on J2SE?

 
Alessandro Ilardo
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone tell me why the @EJB injection has not been implemented in J2SE, do I need to perform I JNDI look up? Or maybe I'm wrong, I do apologize in that case but explanation would be welcome anyway.

Thanks in advance
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15482
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJBs are part of Java EE (Enterprise Edition), so you won't find EJB features in Java SE (Standard Edition).
 
Stephanie Hehreuer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, you can run an app in the "application client container", which is a kind of stripped-down JavaEE container. Perhaps that way you can use @EJB?
 
Fabian Gutierrez
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Injection is not available (except JPA) in JSE basically because there is no one in charge of that task. However, It is possible with JPA because that is what the JPA implementation does :-D. And if you think about it, you always have to ask for the entities instances to the JPA implementation through the API. Eg:

String id = "12345";
Employee emp = entityManager.find(Employee.class, id);

If you consider Spring, the same think happens, it means, that you have to tell: "Spring give me this component", so, it searchs for it, injects its dependencies, and retrieve it to you. Eg:

Resource res = new ClassPathResource("myBeans.xml");
BeanFactory factory = new XmlBeanFactory(res);
Hello bean = (Hello)factory.getBean("hello");


Best Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic