5
Forgive me for the general subject, but I have been researching for some time in various places and I have found nothing that would explain satisfactorily what an EJB is and what it is for.
I am adept at using real examples at all for a better understanding and found few adherents of this style in the tutorials I’ve seen. Usually they say that EJB is essentially a managed component that is created, controlled and destroyed by the J2EE container manager that is running. This tells me nothing or very little. I actually left the text with more doubts than before.
Looking further, I was able to understand that Ejbs are standalone modules that receive requests and return responses, as any method, with the advantage that they can be invoked from external applications. Is that correct?
A simple and practical example would be an EJB that receives a customer’s CPF query whether he is approved or not to make a check purchase. Within this EJB there would be several business rules (account time, occurrences in the credit protection agencies, etc.), even queries to other Ejbs, with the objective of "pulling the record" of the client and finally returning a YES or NO to the one who invoked it. This EJB could be used by any client: a mobile, web or desktop application.
Does anyone have anything else to add?
However, I have some doubts: what is the difference between an EJB and a Webservice? (the latter yes I know what it is and I’ve used it several times).
What is the relationship between JPA and EJB? I’ve done several applications using Hibernate, which is a JPA framework. This means I used EJB?
Thank you!
I will be happy if that question has answers that are not limited to "Ejbs have the characteristics A, B, C" but also include "Feature A serves for such a thing, B has such utility", finally, not only define but clarify why in an application with Ejbs they are considered indispensable, compared to an application without the same.
– Piovezan