This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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");