Rajesh Santhanakrishnan wrote:Hi,
We are using spring framework to develop our web application.
To solve concurrency issue , we have decided to use scope request.
Can any one tell us the advantages/disadvantages of using scope request
Thanks
Rajesh
What do you mean advantages/disadvantages? Request scope means, in terms of Spring beans, that each HttpRequest will get their own instance of a bean set at request scope. If that is truly the scope you need that bean to be in, then make it that scope. Also note, that if there is not an HttpRequest then it will just default back to Singleton.
When you are changing scopes and you have one bean refer to another bean at a different scope, then look to Spring 3.x <aop:scoped-proxy/>
When it comes to concurrency, it depends on what you are storing. For instance, 99% of my beans are always Singleton, because they don't hold any state, and a single instance can therefore handle as many threads running at the same time through it as the Operating System allows. I make sure my Service, Controllers, DAO/Repositories never hold state. I never make my domain objects as beans because they hold state and trying to declare 1 million beans to instantiate my entire customer table database for the Customer domain object, just doesn't make sense.
So you need to look at your definition of concurrency issue, and see if it is correct?
Mark