• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why we need EJB ?

 
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, good day , can i know why we need EJb? when we should use and not ? is there any sample site to use EJB ? thank you
 
author
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nakata,

EJB is a server-side component standard that also now includes lightwieght persistence in the form of JPA. You should use EJB and JPA whenever you are developing server-based Java applications and standards are important to you.

-Mike
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I disagree. You should use EJB when you need the scalabillity and clustering that a well executed EJB system will provide.
You should not use it (or anything for that matter) simply because it's there and it's a nice sounding acronym/buzzword (which is what caused many EJB projects in the past to get into serious trouble).
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And you should use when you know what you're doing !
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<a href="http://www.technicalfacilitation.com/get.php?link=usingejbsWhen" target="_blank">http://www.technicalfacilitation.com/get.php?link=usingejbsWhen to Use EJBs</a>


EJBs are incredibly powerful components that allow developers to easily take advantage of the application server�s security, transaction, naming and distribution services. However, EJBs are also incredibly resource intensive. If you use EJBs excessively, you�ve just bought yourself a one-way ticket to performance problemville.

Before committing to using an EJB, ask yourself the following questions:

F Do I need to manage some serious database transactions?

EJBs are great for managing transactions, and if you have a largely transactional system, EJBs just may be your saving grace.

F Do I need object distribution?
F Are users calling my components remotely?

This is a good case for using EJBs, as EJBs are inherently distributed objects. However, this alone is not a compelling reason to employ an EJB centric solution.

There are many mechanisms for implementing remote distribution including remote method invocation (RMI) and network socket programming, both of which are more efficient than using an EJB.

Needing object distribution is a good reason for using an EJB, but I�d look for another reason or two before committing to an EJB based solution.

F Do I need security down to the method level?

EJBs provide the ability to interact with the security service of the application server, and you can lock EJBs right down to the method level. This type of security would be relatively difficult to implement with regular JavaBeans.

Needing this type of security is a good reason to use an EJB, but it shouldn�t be a reason on its own.

If security is the problem you need addressed, you could probably avoid using EJBs and lock down your applications by securing Servlets and JSPs instead. The Java Authentication and Authorization Service (JAAS) could also be used to facilitate a secure system without using EJBs, but even JAAS introduces an extra level of complexity.

EJBs do indeed provide secure access right down to the method level, and if this is the type of security you need, EJBs might be a viable solution.

F Do I need to make sure that the data my application receives is completely and totally in sync with the data in the database?
F Do I need a persistence model?

CMPs and BMPs address the many difficulties associated with communicating with a database, as they provide a persistent object model that makes sure the data obtained by your application is completely and totally in sync with the database.

Again, if this type of persistence modeling is what you need, go ahead and use EJBs. However, if your application is largely reading data from a database, and data collisions are rare and not likely to be detrimental when the do happen, I wouldn�t use an entity bean framework. In that scenario, I�d look at Java Data Objects (JDO) or Hibernate. Remember, entity beans are incredibly resource intensive. Use them only if you need them.

F Do I need multithreaded access with large workloads

EJBs are inherently multithreaded, and application servers, especially WebSphere, are highly scaleable. This is a good peripheral reason for using EJBs, but I wouldn�t base my decision on multithreading support alone. After all, you can always synchronize methods in a regular POJO (plain ordinary java object.).
Use EJBs Sparingly

The point is, EJBs are incredibly powerful, but they are also incredibly resource intensive. Use them when they make sense, but use them sparingly.

Unnecessary EJBs will slow down your applications and performance will quickly become an issue. There is a good reason why many of the J2EE design patterns demonstrate how you can achieve many of the benefits of using EJBs while minimizing their actually use.

If you choose to use EJBs, choose to use them wisely.

Here's a good link on ejbs:

[url=http://www.technicalfacilitation.com/get.php?link=usingejbs]http://www.technicalfacilitation.com/get.php?link=usingejbs
[ August 27, 2006: Message edited by: Bear Bibeault ]
 
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic