EJB: Enterprise Java Bean
EJB stands for Enterprise Java Bean. It is a Java application programming interface (API) for Java Platform, Enterprise Edition (JEE). It is provided by Sun Microsystems to simplify the development of large, secured and scalable distributed applications.
EJB component is a server-side and platform-independent software component that represents the business logic in scalable, multilayer and distributed applications. Thus, it simplifies the application developer?s work by allowing them to focus on their business logic.
When is EJB needed?
1) When the data and resources are distributed across various sites.
2) When the application is performance-centric and it needs to be scalable.
3) When you need to manage the transactions; EJB container can manage your transactions boundaries.
4) When the application needs encapsulated business logic; separation between business logic and display.
Types of EJB
There are three types of EJB; session bean, entity bean and message-driven beans.
1) Session bean: It implements the business logic of the client, e.g. it can calculate interest on deposits for a banking application.
2) Entity bean: It is a data component that persists the data in the database.
3) Message-driven bean: It manages messages asynchronously, so used in asynchronous communication scenarios like receiving JMS messages.