This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

When not to use EJB?

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In chapt 4 (page 176) of Allen's book there is a brief mention that EJBs can be overkill if the object can be accessed locally and one should use POJOs instead.
This is curious in light of Marc Fleury's comments at our recent User's Group meeting: Never use serialization and always put your EJBs on the same CPU as your web server (which is always practicle with JBoss since there are no licensing fees).
Well, assuming we are creating a web application and everything is on the same CPU and we don't want CMP Entity beans (I hear they are slow and don't support inheritance) when should we use EJB instead of POJOs (plain old java objects)? Do we need EJBs for role based security? Don't Apache HTTPD and Apache Tomcat implement authorization and authentication? I believe they do because I just used it!
I have not heard much encouragement about statefull session beans either.
I am tempted to conlude that EJBs are not terribly useful for Web applications and are mostly useful for 2 tier applications where there is no web server to provide authorization, authentication, no browser to support session state (with cookies and hidden fields).
Please critque my logic and assumptions here if you disagree!
Thanks,
Siegfried
 
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> ...we don't want CMP Entity beans (I hear they
> are slow and don't support inheritance)
You can subclass CMP entity beans by (i) creating a class A that implements EntityBean, (ii) creating an abstract class B that extends class B , (iii) coding your local and remote object and home interfaces so that they account for the methods in both classes, and (iv) designing your ejb-jar.xml file so that its CMP and CMR details reflect the appropriate methods in classes A and B.
This problem is not specific to CMP entity beans -- it's common to any sort of entity bean and session bean.

> when should we use EJB instead of POJOs (plain
> old java objects)?
You want to use EJBs if you want to take advantage of the transaction, security, etc. and other services provided by the EJB container.

> Do we need EJBs for role based security?
You don't need it but it speeds up the development process and cuts down on coding errors.

I think CMP beans perform quite well once you learn how to set up caching, optimistic locking, and other performance enhancing tweaks that may or may not be implemented by your EJB container.
Cheers,
Darryl
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Wrox "Design and Development" book suggests using JDOs or DAOs rather than entity beans in most, if not all, circumstances.
 
Siegfried Heintze
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response Darryl.
Do agree or disagree about Allen's and Bambara's comment that the only time not to use EJB is when your object is local?
Sieg
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic