I am making a Java EE application just to use what I learn while reading in the books. I made a simple Entity and a DAO object that do different actions on this Entity such as create, update etc. Then in my EJB I want to use this DAO object so that I later can expose it to JSF etc.
I am having a little problems of understanding how to use objects of different classes in different layers of my application. How do I expose them to each other?
Do I just do as in regular Java SE? Have properties for the different classes and instantiate them in the classes I want? (No probably not, I have seen the use of @Inject and so on, but I do not understand one bit of it. And not when I can use it either)
I would apprciate some text on when/how we use the different annotations and how we connect different layers rather than just some code showing it.
I am on the Java chat if anyone have some spare time =)
You’re asking too general questions. Grab some decent book on Java EE (there are tons of them). For better understanding of dependency injection, I’d recommend official Weld documentation. However here is a typical example aimed to show you how to connect different Java EE layers:
JPA Entity:
EJB bean:
JSF controller (let’s assume it’s CDI-bean):
xhtml page:
Update
Some books that might help:
These are quite popular and cover a lot of ground.