Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is the managed bean singleton?

 
Ivan Lou
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm beginner of learning jsf. I want to know whether the managed bean is singleton
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18218
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes and no. It depends on how "single" you want it.

An application-scope managed bean is truly single. Only one of them per copy of the deployed webapp per server VM.

A session-scope managed bean is singleton on a per-user basis, but with multiple users, each user gets a unique and separate bean instance.

A request-scope bean is singleton on a per-request basis, but there can be lots of requests.

The "single"-ness of managed beans is determined by the fact that each bean ID in faces-config must be unique, so only one bean with that ID may exist in the context of its defined scope.

Only application scope is really singleton, the rest, like I said are unique, but only withing their contexts.
 
Ivan Lou
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Yes and no. It depends on how "single" you want it.

An application-scope managed bean is truly single. Only one of them per copy of the deployed webapp per server VM.

A session-scope managed bean is singleton on a per-user basis, but with multiple users, each user gets a unique and separate bean instance.

A request-scope bean is singleton on a per-request basis, but there can be lots of requests.

The "single"-ness of managed beans is determined by the fact that each bean ID in faces-config must be unique, so only one bean with that ID may exist in the context of its defined scope.

Only application scope is really singleton, the rest, like I said are unique, but only withing their contexts.


Thank you, Tim Holloway.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic