What is EJB
EJB is an acronym for enterprise java bean. It is a specification provided by Sun Microsystems to develop secured, robust and scalable distributed applications.
To get information about distributed applications, visit RMI Tutorial first.
To run EJB application, you need an application server (EJB Container) such as Jboss, Glassfish, Weblogic, Websphere etc. It performs:
EJB application is deployed on the server, so it is called server side component also.
EJB is like COM (Component Object Model) provided by Microsoft. But, it is different from Java Bean, RMI and Web Services.
When use Enterprise Java Bean?
Types of Enterprise Java Bean
There are 3 types of enterprise bean in java.
Session bean contains business logic that can be invoked by local, remote or webservice client.
Message Driven Bean
Like Session Bean, it contains the business logic but it is invoked by passing message.
It encapsulates the state that can be persisted in the database. It is deprecated. Now, it is replaced with JPA (Java Persistent API).
Difference between RMI and EJB
Both RMI and EJB, provides services to access an object running in another JVM (known as remote object) from another JVM. The differences between RMI and EJB are given below:
EJB and Webservice
In EJB, bean component and bean client both must be written in java language.
If bean client need to be written in other language such as .net, php etc, we need to go with webservices (SOAP or REST). So EJB with web service will be better option.
Disadvantages of EJB