Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it true use stateless session bean unless neccessary  RSS feed

 
uday dustin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a test program to compare the difference of using stateless session bean(which claims resource pooling apart from security,transaction etc...) against Plain Java Class , both uses same business logic...the test shown that SLSB takes around 100 times more than creating a new Plain java class and call the business methods...the methods are called for 100,000 times.

Coming to point what is the use of SLSB unless neccessary like calling a remote location.
Can anybody say with pratical example when can a SLSB can be used in one Application Server...(one I know calling a Entity Bean)...
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should only use EJBs if you have to have the benefits of an App Server and the security/transactions and pooling. Otherwise, it is best to not use EJBs. If you just need the remoting capabilities, I'd suggest looking at things like the SPring framework.

But in either case, always keep your code out of the Bean directly and in Plain Old Java Objects. So a bean should really only be a facade, very thin, just like an interface, that passes all the calls to the real POJO that does the real work, then if you need to move that business logic out of the App Server and accessed outside the App Server Container you can without haveing to do anything else.

Mark
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by uday dustin:
Coming to point what is the use of SLSB unless neccessary like calling a remote location.


Multiple reasons to use SLSB or SFSB, but clearly you have to decide which of these matter to your application. One of my favourite uses of session beans is to leverage existing components for a new use by creating a special-purpose facade. The new use may require different combinations of beans, it may require different transactionality settings, different object pool tuning options, it may or may not be run in a clustered environment, etc. Comparing any kind of EJB to how you write single-threaded desktop Java code is always going to make EJB come out worse than a POJO because it isn't solving the same problems as a POJO. If POJO does what you need, you should use it, not EJB.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!