Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Managed ben doubt

 
Maya Pillai
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my application all the managed beans are in scope session. Will it cause any performance issue? Do we need to serialize this bean objects.

Can anyone tell me the best approach. I am using jsf1.2

Thanks.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well yes. The data must be stored somewhere, in memory or on disk.
Only data that needs to be stored you should store and for other classes you should make them stateless.
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a choice, you should use request scope instead of session scope. That's because the server has to keep objects on a long-term basis, and the more objects you're keeping, the more RAM it eats up. Request scope objects exist only while a request is active, so they take a smaller "bite",

However, JSF does tend to force you to use session scope in a lot of cases where you wouldn't otherwise have to. JSF2 eases some of this by adding View scope.

Session scope objects (including non-JSF session-scope) objects need to be serializable. Some appservers will get very annoyed if you don't declare session objects as serializable. That's because if the appserver needs to free up memory by "paging" objects out or if the appserver needs to transfer the session to another VM, the data must be serialized/deserialized.

Of course, if you say something's serializable, you must mean it. Otherwise, if the data goes through serialization/deserialization, the deserialized copy of the object may be missing critical information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic