EJB
EJB
EJB
RMI EJB
RMI is built on the top of socket programming. EJB technology is built on the top of RMI.
Disadvantages of EJB
1. Requires application server
2. Requires only java client. For other language client, you need to go for webservice.
3. Complex to understand and develop ejb applications.
Session Bean
1. Session bean encapsulates business logic only, it can be invoked by local, remote and
webservice client.
2. It can be used for calculations, database access etc.
3. The life cycle of session bean is maintained by the application server (EJB Container).
Stateless Session bean is a business object that represents business logic only. It doesn't have
state (data).
In other words, conversational state between multiple method calls is not maintained by the
container in case of stateless session bean.
The stateless bean objects are pooled by the EJB container to service the request on demand.
It can be accessed by one client at a time. In case of concurrent access, EJB container routes
each request to different instance.
1. @Stateless
2. @PostConstruct
3. @PreDestroy
There is only two states of stateless session bean: does not exist and ready. It is explained by
the figure given below.
EJB Container creates and maintains a pool of session bean first. It injects the dependency if
then calls the @PostConstruct method if any. Now actual business logic method is invoked by
the client. Then, container calls @PreDestory method if any. Now bean is ready for garbage
collection.