What makes a beanless session more than a normal class?

What would a beanless session provide only a regular class that has the same methods? It seems that the session with the bean state can be distributed out of the box, and the container will make sure that the state looks the same for clients anywhere. With a beanless session, what is provided if you don't get a normal class?

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

+4
source share
2 answers

A beanless session provides the application container with information about the intentions of the services provided. Since it has no state, the application container can decide at any time to destroy the bean and recreate it the next time it is needed.

Without this semantics, an application container cannot optimize your application for speed / memory / any other. So, although a beans-free session is mostly reminiscent of POJOs, they provide some additional β€œhints” for the application server.

If you look at how a stateless beans session should be implemented using the EJB3 specification, you will see a lot of similarities between it and a regular POJO (besides additional annotations).

+5
source

EJBs provide you declarative security, transactions, and remote access. When you call one of the EJB methods, you actually go through the stack of interceptors that provide the above levels of functionality.

A regular simple Java object will not do this. Of course, if you do not need it, then EJBs are not needed.

+8
source

All Articles