Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Stateless session beans

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

What are the advantages of implementing the business logic in stateless session bean rather than implementing business logic with static methods in a java class.


Thanks,
Shyam
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With Stateless beans you will not worry about concurrency of dbConnections, objetcs. [=
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vShyam Sundar wrote:

What are the advantages of implementing the business logic in stateless session bean rather than implementing business logic with static methods in a java class.


You won't get any of the EJB semantics (like transactions) in a plain Java class. Furthermore, the stateless beans can have non-static fields (although the state shouldn't be relied upon between business method invocations), whereas your static methods on a plain Java class will not be able to store any object state.
 
vShyam Sundar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all your replies. Now my understanding after much surfing for the question i posted goes like this.

When we use stateless session bean, When ever a client request comes in, the EJB container creates an instance of the bean i.e., EJB container pulls out an instance of the bean from a session pool. In this way we can achieve scalability and moreover performance tends to improve with EJB thread management,security and transactions. Whereas when you use your java classes, you always need to create an instance for the class which in turn depends on the heap memory.

Lets say for example an application with stateless session bean invoked by 1000 users at a particular time will have significant performance over same 1000 users accessing an application without stateless session bean.

And last but not the least, Maintenance of business logic which happens to change often(depends on the application) will be much easier with EJB because of loose coupling between the client and bean Whereas with a normal java class this tends to be more tedious.

Correct me if i my understanding was wrong. and also add to this thread if there are other benefits of using a stateless session beans over normal java classes.


 
reply
    Bookmark Topic Watch Topic
  • New Topic