Re: <strong><font color="red">What are The Real advantages of EJB's?</font></strong>
Tuesday, May 29, 2001 03:39 PM
Its very simple question to answer but its a experience to understand it.
I will try to answer :
First of all, why session beans ?
aren't they simple java classes ? yes!
they are ! But these are classes which are meant to be running in ejb server environment.
whenever a http request comes , your servlet will create a objetc of the class and will use it and then it will be garbage collected.
while in ejb server environment , u dont control the life of these objects rather server will create a pool before even first request comes and you are simply assigned one of these and taken back after u r finished.
so instantiation and killing is avoided for each request.It saves a lot of processing and memory which is critical for any enterprise application.
secondly, entity beans are answer to the persistance problem.You dont need to write embedded sql inside ur java classes to access database.It is handled by container software.
thirdly, u dont need to haggle around with rmi problems , it is taken care of by ejb server.
most important of all, it supports 2-phase commit.
you can have a transaction spawned across multiple server connections and u dont need to code for this functionality.
with ejb 2.0 coming up , OR mapping and message beans are introduced , so advantages are not countable.