Spring bean request scope definition

To use spring bean query scope, is this the correct definition?

<bean id="shoppingCart" class="ShoppingCart" scope="request">
<!-- This requires CGLIB --> 
<aop:scoped-proxy/>
</bean> 

I changed this from an example bean session and changed only the scope definition, not sure proxy

I took this example from this link, you can see the full xml:

http://wheelersoftware.com/articles/spring-session-scoped-beans-2.html

+3
source share
1 answer

As a rule, yes, that’s right.

If for each request you received a request with a bean scope directly from BeanFactory, then you do not need a proxy.

But you need a proxy server if you are going to use a soped bean request as depenedncy for a singleton scoped bean, for example, for example:

@Controller
public class MyController {

    @Autowired
    private ShoppingCart shoppingCart;
}

. reference beans.

, , JDK CGLIB. spring .

+6

All Articles