Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a stateless session bean provide over just a normal class?

What would a stateless session bean provide over just a regular class that has the same methods? It seems that a stateful session bean can be distributed out of the box and the container will make sure that the state looks the same to clients anywhere. With a stateless session bean what is provided that you would not get with a normal class?

Is it just that your EJB tier can fail over if you have a distributed environment? It seems to me that you can get a local or remote instance of a stateless session bean, if I only use one server for my application and thus never use the remote interface is there any benefit?

like image 555
benstpierre Avatar asked Dec 10 '22 18:12

benstpierre


1 Answers

EJBs give you declarative security, transactions and remoting. When you call one of the EJB's methods, you actually pass through a stack of interceptors that provide the above layers of functionality.

A Plain Old Java Object wouldn't do any of that. Of course, if you don't need any of that, then EJBs are not necessary.

like image 62
skaffman Avatar answered Jun 02 '23 22:06

skaffman