For using spring request scope bean is this definition correct?
<bean id="shoppingCart" class="ShoppingCart" scope="request">
<!-- This requires CGLIB -->
<aop:scoped-proxy/>
</bean>
I modified this from a session scope bean example, and changed only the scope definition, not sure about the proxy thing
I took this example from this link, you can see the full xml:
http://wheelersoftware.com/articles/spring-session-scoped-beans-2.html
Generally – yes, it’s correct.
If for every request You’d retrieve the request scoped bean directly from the
BeanFactory, then You don’t need the proxy.But You need the proxy if You’re going to use the request soped bean as a depenedncy to singleton scoped bean, for example like this:
See this reference page for more details about scoped beans.
As a side note I’d advise to use standard JDK interface-based poxies instead of CGLIB whenever possible. More about proxying with spring can be found in documentation.