| Author |
Stateless beans - still hazy about caching
|
Billy Vandory
Ranch Hand
Joined: Mar 23, 2010
Posts: 57
|
|
I have a ServletContextListener where I do a lookup and store it in an attribute, as per below:
As I kind of understand it, the container has a Stateless bean pool. Would doing the above and using getAttribute to retrieve the bean in a servlet, say, still use the pool, or would it refer to the same bean instance? Or are caching local stateless beans even required? (ps: i know that this way isn't the best practice, I'm just trying to figure out the behaviour of caching stateless beans.)
Thank you very much,
Billy
|
 |
Billy Vandory
Ranch Hand
Joined: Mar 23, 2010
Posts: 57
|
|
I did another test which has me a bit confused. When I call a method on a stateless bean where the method does not return for 10 seconds or so, all other methods on the bean are blocked. If I change the code to do a separate lookup for each method I want to invoke, the methods do not block, which leads me to believe that I should not cache the bean lookup ?
|
 |
Gaurav Ag Agarwal
Greenhorn
Joined: Mar 24, 2010
Posts: 6
|
|
|
I saw what you did.. You can go from through this tutorial if you need it has all your basic details at http://www.roseindia.net/javabeans/javabeans.shtml
|
With Regards,
Gaurav Agarwal
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8143
|
|
Out of curiosity, how is that "course" related to this specific question? A quick look at that page shows that it provides an overview of EJB applications, but is no way related to the specific question which Billy asked in this thread.
|
[My Blog] [JavaRanch Journal]
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8143
|
|
Billy Vandory wrote:I did another test which has me a bit confused. When I call a method on a stateless bean where the method does not return for 10 seconds or so, all other methods on the bean are blocked.
Are you sure it's a stateless bean? And which application server is this?
|
 |
Billy Vandory
Ranch Hand
Joined: Mar 23, 2010
Posts: 57
|
|
Jaikiran Pai wrote:
Billy Vandory wrote:I did another test which has me a bit confused. When I call a method on a stateless bean where the method does not return for 10 seconds or so, all other methods on the bean are blocked.
Are you sure it's a stateless bean? And which application server is this?
Yep, it's annotated as @Stateless
App server is Geronimo with an OpenEJB plugin.
|
 |
Billy Vandory
Ranch Hand
Joined: Mar 23, 2010
Posts: 57
|
|
Jaikiran Pai wrote:
Gaurav Ag Agarwal wrote:I saw what you did.. --snip--
Last Summer?
|
 |
 |
|
|
subject: Stateless beans - still hazy about caching
|
|
|