user1154644
user1154644

Reputation: 4609

Advantage of using EJB's

I just took a class on Enterprise Web Development with JAVA, and we built an application that used Enterprise Java Beans. I'm trying to improve my understanding of EJB's, and was thinking about the advantages of using EJB's.

For our application, we injected an EJB into our servlets. The EJB's talked to the business logic tier (which was deployed as a jar). I was thinking about what the advantage is of using an EJB, instead of just having the servlet interact directly with the business tier JAR.

I came up with 2 reasons:

1) The EJB's allow you to construct the application in a modular fashion, since each EJB can be responsible for certain categories of back-end responsibility.

2) Since the EJB's are deployed to the EJB container, they can be looked up via their JNDI name, and so if other applications are deployed on the server, and have the need to perform similar functions, they can take advantage of the EJB's that are already present on the server.

Am I on the right track? Do EJB's provide more advantages than that? I know that MDB's are used in conjunction with the JMS API, but I'm more looking at session beans.

Upvotes: 0

Views: 755

Answers (1)

duffymo
duffymo

Reputation: 308753

That's fine, but you need to recognize a few things:

  1. You can construct applications in a modular fashion without EJBs, with or without Java. It's one choice among many, and it's not optimal.
  2. Applications may or may not share EJBs that way; certainly NOT session EJBs.
  3. EJBs were announced at Java One way back in 1999. They're on version 3.0 of the spec. It's much better than it used to be, but still far from perfect.
  4. Java EE app servers are heavyweight things.
  5. Spring and dependency injection frameworks let you create modular Java apps without EJBs. Some people prefer them (like me).
  6. Java EE app servers use a thread-heavy solution that's very request/response centric. A more modern approach would be event-based, non-blocking IO using vert.x or node.js

It's great that you're learning, but don't be fooled into thinking you've reached the top of the food chain. The rest of the world is going in the direction of HTTP web services, not EJBs.

Upvotes: 2

Related Questions