Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should we use EJB? [closed]

Tags:

java

ejb-3.0

What is EJB, and why we should use it? Please explain in simple language. Thank you.

like image 649
mriganka3 Avatar asked May 09 '11 12:05

mriganka3


People also ask

Why should we use EJB?

Benefits of EJB EJB simplifies the development of small and large enterprise applications. The EJB container provides system-level services to enterprise beans, the bean developer can just concentrate on developing logic to solve business problems.

Does anyone use EJB anymore?

EJB is still there and growing up. There are many new features (SOAP/RESTful webservice, JPA entities, JAXB...) depend on it or at least reuse the philosophy of developing.

What is difference between EJB and Spring?

Basic Difference Between the Two. First, the fundamental and apparent difference is that EJB is a specification, whereas Spring is an entire framework. The specification is implemented by many application servers such as GlassFish, IBM WebSphere and JBoss/WildFly.


1 Answers

The EJB or Enterprise Java Beans are plain java classes (since version 3.0) with annotations that enable to you write the business logic of your applications and later deploy it (or install) on a Java Enterprise Edition Server.

You must consider use EJB if you wish to take advantage of the following services provided by the Java Enterprise Edition (Java EE) server:

  • Clustering. You can deploy your EJB on a cluster environment (dependent of Java EE Application Server), this provides to you Fault Tolerance and High Availability.
  • Concurrency without use Threads. All EJBs are instantiated through a pool of objects then your application gains on performance and without Thread complexity.
  • Transactionality through JTA. All EJBs can benefit from Transactionality management for different resources, the most important Databases, using annotations is easy to delimit the frontier of every transaction and manage them.
  • Connection Pool to Database. All ejb can access to connection pools defined into the Java EE Application Server, this connection pools provide an abstraction of the database complexity, by example you can use a XA Datasource that enables to you do Two Phased Commit to different databases.
  • Security. All ejb can use JAAS for secure the applications. JAAS is configured into the Java EE Application Server and lets you to Authenticate and Authorize the methods of your EJB through different providers just with configuration (By example using Active Directory, LDAP or Database).
  • Schedule service. All ejb can use the Timer Service that enables to you implement task for further execution or inclusive for repetitive execution.

There is other services and benefits but I think that these are the most importants. If you don't need these benefits my recommendation is that you don't use EJB (not all applications are Enterprise Applications).

like image 134
Ernesto Campohermoso Avatar answered Sep 21 '22 06:09

Ernesto Campohermoso