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.
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");
SCJP 1.4, SCWCD 1.4, SCBCD 5, SCJD 5
subject: Why EJB injection is not available on J2SE?