aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How could I define when I should use or not use EJB? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How could I define when I should use or not use EJB?" Watch "How could I define when I should use or not use EJB?" New topic
Author

How could I define when I should use or not use EJB?

Marco Azevedo
Greenhorn

Joined: Jan 27, 2005
Posts: 2

Hi,
What the benefits of using EJB?
What requirements does an application should have to justify the use of EJB?

Thank you!

Regards,
Marco.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Welcome to CodeRanch, Marco!

There are many ways to compose enterprise applications' business layer. Early EJB version were bit of hard to use since there were many unnecessary (compared to other lightweight frameworks came lately) work/development to be done by the developer. Most recently there have been a huge improvements to the specs similar to that of the lightweight (web/business) frameworks provide.

EJBs are primarily focused on the business layer (and the persistence layer with the JPA support) of an application. There are many other frameworks which can be used to achieve similar results. But it can be a preference of a given project/company to use certain technology provider for their application. And most importantly the ease of use (as EJBs becoming more lightweight and easy to use over time) is a key factor.

You might want to check on some of the new features listed in FAQ for more information.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

Also something to consider is that EJB design pattern came about before SOA design pattern. With SOA, the infrastructure is more immediate, and combinable. You can create new applications through composite of other , more granular services. If you contrast EJB with SOA, you'll gain some insight on when to use and not use EJB.
Reza Rahman
author
Ranch Hand

Joined: Feb 01, 2005
Posts: 580
    
    5
You would need EJBs in a Java EE application when you need services such as transactions, security, pooling, monitoring, asynchronous processing, scheduling and the like. The fist and second chapters of EJB 3 in Action answers this question in detail.


Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
Michael Remijan
Author
Ranch Hand

Joined: May 29, 2002
Posts: 123
    
    5

As Reza mention, pretty much any business logic you have in your application is going to need these services eventually. So it's a good idea to start using EJB's from the beginning. Remember EJB lite runs inside the Web container so if you are "only building a web-app" there is no reason not to use EJBs since @EJB is supported inside a WAR file without the need to deploy them separately. With all this said, it is a great idea to use them.


Java EE Evangelist — Author, EJB 3 in Action 2nd Edition — Java Community Process Member
Marco Azevedo
Greenhorn

Joined: Jan 27, 2005
Posts: 2


I'm studying about every tip you have told me.
Thanks for helping me , guys !
Dieter Quickfend
Bartender

Joined: Aug 06, 2010
Posts: 542
    
    4

Roger Sterling wrote:Also something to consider is that EJB design pattern came about before SOA design pattern. With SOA, the infrastructure is more immediate, and combinable. You can create new applications through composite of other , more granular services. If you contrast EJB with SOA, you'll gain some insight on when to use and not use EJB.

I don't really see the contrast. They are not mutually exclusive. In fact, there is much to be said for implementing SOA using EJB, even without exposing your EJB's as WS. Depending on the interoperability requirements and Java EE server availability, I would prefer to implement SOA as Remote EJB's.

I don't see the use of choosing the slowest option by default. Except "everyone's doing it these days".


Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How could I define when I should use or not use EJB?