0

Haven't used EJB3, but by reading a tutorial, EJB3 looks like mostly for manipulating data in database through JPA (of course, it contains other business logic). Just curious, if no database is quired, is it still beneficial to use EJB3 or it just adds complexity to an application? Will POJO be a better choice for implementation?

sarahTheButterFly
  • 1,894
  • 3
  • 22
  • 36

2 Answers2

4

Big part of EJB benefits is coming from transactions and persistence.

But even without them you may benefit from EJBs. It can give you a proven clustering and balancing model. It can give you the declarative security. It can give you MDBs which are a convenient way to listen to JMS queues/topics and timers.

All above can be done using third-party libraries, such as Spring. EJBs though are highly consistent, while to get, for instance, clustering and security you may need to combine two products, and it's not guaranteed they will work together well and won't need much glue.

Vladimir Dyuzhev
  • 18,130
  • 10
  • 48
  • 62
  • I'm looking at GlassfishV3 which implements the JEE6 stack, which is supposed to glue things together.. – sarahTheButterFly May 04 '11 at 01:02
  • I disagree with the part about clustering and security. Spring can integrate with JAAS, and Tomcat can provide clustering. Spring apps usually deploy on Java EE app servers, so all the services they provide for EJBs accrue to Spring POJOs as well. – duffymo May 04 '11 at 01:39
  • @duffymo In what way do you disagree that EJBs provide security/clustering? Clearly, Spring/Tomcat are substitutes, but that doesn't invalidate the EJB feature set. – Brett Kail May 04 '11 at 05:38
2

EJBs are transactional, distributed components deployed on an app server that manages lifecycle, threading, and other services. Persistence is just one type of EJBs. You still might find stateless, stateful, or message EJBs useful, even if you don't want to use entity beans.

With that said, you can create POJO components that are stateful, stateless, persistent or message-driven. You don't need EJBs; something like Spring can be a good alternative.

duffymo
  • 305,152
  • 44
  • 369
  • 561