Help me to understand JSF managed bean scope from concurrency view
Asked Answered
S

1

1

Can anyone help me to understand the JSF managed bean scope from a concurrency perspective ?

My Understanding:

Once i have a bean scoped in a session scope that's mean : there is only one user can access this managed bean so there is no possibility to concurrency occur.

Also, once i use a bean in a request scope then this bean will be created once a request had initiated and that bean will be removed once a response returned. (each clients have different copy of this bean)

Also, once i use a bean in a none scope then once the user call the bean it will be created and after finish the call the bean will be removed.

But once i have a bean in an application scope that's mean multiple client can access this bean, so if i have a critical data it must be protected by synchronization.

All your inputs are highly appreciated.

Sulphurize answered 11/8, 2011 at 11:21 Comment(0)
F
4

I think your understanding of the lifespan of each of the scopes is fine.

However, I think your understanding of when to apply synchronization is not good. Whenever you need to synchronize the methods of a bean in a certain scope, then this is usually an indication that the scope of the bean is too wide for the data it holds. You should then put the bean in a more narrow scope or to move the data into another bean in a more narrow scope, so that synchronization is not necessary.

You should put request scoped data (presentational data, synchronous form data, etc) in the request scope. You should put view scoped data (asynchronous form data, rendered attribute conditions, "hidden" values, etc) in the view scope. You should put session scoped data (logged-in user, user preferences, user-specific data, etc) in the session scope. You should put application scoped data (global dropdown list values, configuration settings, etc) in the application scope.

Frannie answered 11/8, 2011 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.