Are there any plans to introduce an Java annotation equivalent of the <aop:scoped-proxy/> at some point?
Are there any plans to introduce an Java annotation equivalent of the <aop:scoped-proxy/> at some point?
It seems to exist but only as part of Spring Java Config.
Joerg
This post can contain insufficient information.
Yes, I found that too. However it's not really what I was looking for. That would require me to write a separate Java class similar to using the separate XML based configuration. I don't see the advantage. When you write the annotations directly into the original class it keeps everything in one place so it's simpler.
I too am interested in this.
Spring Java Config annotations cannot be used in this way, they are used only as a part of java class that represents the whole java configuration, as opposed to xml config.
So, we need something like @ScopedProxy that works on individual beans, together with @Component and @Scope.
After some digging I found the solution. You define component-scan definition like this:
All scoped beans will then be automaticaly proxied. It seems that the default value of "scoped-proxy" attribute is "no", which would mean no proxies would be created.HTML Code:<context:component-scan base-package="your.package" scoped-proxy="interfaces"/>
The possible values for "scoped-proxy" attribute are: "no", "interfaces" and "targetClass".
Regards,
Igor.
<context:component-scan base-package="your.package" scoped-proxy="interfaces"/>
Thanks, that works for me. I do like the @ScopedProxy annotation idea better though. This works but you need to be careful to keep your proxied classes separate in some way from your non-proxied ones - probably a different package.
Last edited by jdhwpgmbca; Nov 22nd, 2007 at 09:40 PM.
Don't forget that scoped-proxy="interfaces" creates 'standard JDK proxies'
This is different from the default for "<aop:scoped-proxy/>" which creates CGLIB based proxies.
As a result your scoped bean needs to implement an interface and all your collaborators have to reference the interface.
http://static.springframework.org/sp...ection-proxies
Hi
When you place a bean in the session using the @scope.
How do you access to it in the jsp page ?
I would like to kwon if a value is store in the http session and how the get the name of the object in the session
Regards
what sense does it make to use request/session-scoped beans without <aop:scoped-proxy/>? Shouldn't Spring either activate that as a default or throw an exception? I currently have "request" scoped beans running that get passed from request to request.... (Spring 3.0.7)