码迷,mamicode.com
首页 > 编程语言 > 详细

两种写法实现Session Scope的Spring Bean

时间:2015-12-23 19:50:30      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:

xml based:

<bean id="localRepository" class="com.demo.bean.LocalRepository" scope="session">
    <!-- To effects the proxying when used as dependencies by singleton beans. This requires CGLIB -->
    <aop:scoped-proxy />
</bean>

 

Java based:

@Component
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class LocalRepository implements DisposableBean {
    // TODO  

    @Override
    public void destroy() throws Exception {
        // cleanup
    }
}

ScopeProxyMode.TARGET_CLASS means:

Create a class-based proxy (uses CGLIB).

两种写法实现Session Scope的Spring Bean

标签:

原文地址:http://www.cnblogs.com/haibinyuan/p/5070975.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!