annotation equivalent of <aop:scoped-proxy>

青春壹個敷衍的年華 提交于 2019-12-17 15:31:09

问题


I am moving from an xml config to annoations. i want to convert a session scoped bean that is

<aop:scoped-proxy>

can this be done with annotations, and if not, what can i do to still keep that declaration working?

edit: I am interested in doing this in Spring 2.5


回答1:


in the spring context xml, do something like:

<context:component-scan base-package="com.startup.failure" scoped-proxy="interfaces" />

Note that you would need to write interfaces for all classes in that package, though.




回答2:


In Spring 3.0 it can be specified by the proxyMode attribute of @Scope annotation:

@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)



回答3:


In Spring 2.5.x

If I do in spring-context.xml something like

<context:component-scan base-package="com.startup.failure" scoped-proxy="TARGET_CLASS" />

So this way I don't need my proxied beans to implement interfaces? (using CGLIB not JDK standard). Didn't tested this but i think it should work. Of course you need to have cglib library, you need it with <aop:scoped-proxy> anyway.



来源:https://stackoverflow.com/questions/4503606/annotation-equivalent-of-aopscoped-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!