|
From: Juergen H. <ju...@in...> - 2006-08-03 16:24:45
|
Well, access via the "BeanFactory.getBean" method does not require a proxy -
so if anyone uses straight BeanFactory access, for example in turn to wire
request-specific command objects (such as WebWork or JSF actions) or any
intermediary Spring prototype beans, raw scoping is perfectly sufficient.
Additionally, raw scoping does not require anything beyond Spring's core
container, and will work with any kind of target object (since it doesn't
impose any proxying requirements on the target class).
This is why proxying needs to be explicitly requested: It is the more
specific functionality - from a Spring subsystem point of view, from an
external dependency point of view (CGLIB), and from a
requirements-on-target-class point of view.
That said, we have considered auto-proxying of scoped objects if they are
referenced from a singleton bean definition, since this is a pretty clear
indication that the scoped object is supposed to be proxied. However, that
hasn't been implemented yet, since it's not really trivial to handle this in
a general fashion. It's still under consideration, though.
For the time being, I actually don't think that adding the
<aop:scoped-proxy/> tag is such a burden... in particular since there
shouldn't be that many scoped objects in a typical application in the first
place!
Juergen
_____
From: spr...@li...
[mailto:spr...@li...] On Behalf
Of And...@ub...
Sent: Thursday, August 03, 2006 6:11 PM
To: spr...@li...
Subject: [Springframework-developer] Is <aop:scoped-proxy/> redudant
forScoped beans?
Hi,
I've been looking over the new scoped bean functionality, and it looks
really good. However, I'm a bit puzzled about the need to have the
<aop:scoped-proxy/> as part of the definition. I understand why I proxy is
needed, I'm just not sure why a user has to specify one. Simply put, if the
scope is "session" or "request" (or custom for that matter), should these
beans not automatically be using a scoped proxy without having to explicitly
say so?
>From the Spring docs it shows we need to do this:
<bean id="userPreferences" class="com.foo.UserPreferences" scope="session">
<aop:scoped-proxy/>
</bean>
Put another way, is there any case when you would not want to proxy these
beans? Or, in general use, if most people do use a proxy, but there is a
rare chance that someone wants to use a non-proxied bean, then can a
parameter be set up accordingly?
eg:
<bean id="userPreferences" class="com.foo.UserPreferences" scope="session">
<aop:no-proxy/>
</bean>
Or
<bean id="userPreferences" class="com.foo.UserPreferences" scope="session"
proxied="false" />
Regards,
Gus.
|