• 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

Performance Issue at the worst...

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,
I have an application where I have used the authentication mechanism. Now in the authentication mechanism I have a class WBCredentialVerifier. I have implemented singleton pattern where I created a single object and this object is created will look up the EJB object . I have used the singleton pattern to facilitate the looking up of the object only once. Now will this be a bottle neck if more than one user is accessing the business methods of the object because this will be only a single object. This has been a performance issue.
Regards,
shekar.
 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using the singleton pattern? For authentication, you wouldn't be looking up the same value in the EJB each time. So it would be ok to draw from a pool of beans.
 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using singleton pattern because the first time I create an object of that class it will look up in the constructor of the class. But the next time another uses tries to create an object of the class he need not again go to the constructor and do the lookup. this would reduce the lookups to only one. So this would be the advantage of creating a single object. But because of the creation of only one object does the following happen.
When A logs in he creates the instance of the class and looks up the EJB and he calls some methods in the same ejb. will he keep the object with him until and unless he executes all the methods.
Therefore when user B logs in just after A he cannot get the instance of the class because user A already has acquired it and until and unless the user A releases it user B cannot get it. this would be same case for 10 users. I guess this would result in low performance. Is the reasoning correct. What should be the way I should be dealing with it so that the look ups for the session bean are very less and performance is more.
any help will be of great help.
thanks and regards,
shekar.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chandra Bairi:
When A logs in he creates the instance of the class and looks up the EJB and he calls some methods in the same ejb. will he keep the object with him until and unless he executes all the methods.
Therefore when user B logs in just after A he cannot get the instance of the class because user A already has acquired it and until and unless the user A releases it user B cannot get it. this would be same case for 10 users. I guess this would result in low performance. Is the reasoning correct.


No, you can have as many users use the object at the same time, *concurrently*, as you wish. This works without problems for stateless session beans - for statefull beans, some kind of synchronization might be necessary.
 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a stateless session bean. Will there be a performance problem in this case.
shekar.
 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what will be the case if i use a java bean instead of stateless session bean.

regards,
shekar.
 
Jeanne Boyarsky
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ilja,
Are you limited to one user being in the session bean at a time? I thought that was the reason for pooling session beans.
Chandra,
You definitely won't have a problem with regular java beans. But then you loose the benefits of EJBs. It is still possible to do what you want without a complete singleton. You can still use a singleton/cache for the lookup and have a regular class call it. Then you could direct the user to different session beans. (which will only provide some benefit if my question to Ilja is correct)
[ March 18, 2004: Message edited by: Jeanne Boyarsky ]
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeanne Boyarsky:
Are you limited to one user being in the session bean at a time?


I would be surprised of you were - but I am far from being an EJB expert...

You definitely won't have a problem with regular java beans. But then you loose the benefits of EJBs.


Of course you would also loose its complexity. In my humble opinions, for many projects EJBs are just overkill...
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic