使用ThreadLocal解决代码分层问题

时间:2019-11-12 02:44:58
【文件属性】:
文件名称:使用ThreadLocal解决代码分层问题
文件大小:1.09MB
文件格式:ZIP
更新时间:2019-11-12 02:44:58
ThreadLocal javaee开发常见的模式有MVC模式,在C层中常常会再次分层,如:servlet(web层)、service(业务逻辑层)、dao(数据访问层),其中service和dao最容易混在一起,如转钱交易场景,service层需要执行“事务”操作,会用到数据库连接对象(Connection),这就与dao层混在一起了,因为Connection是dao层才会用到对象,但如果把“事务”放到dao层,也是将service层与dao混在一起,因为转钱交易这个 事务应该由service层来做。所以,使用ThreadLocal可以解决这样的分层问题。
【文件预览】:
day14_01_transfer_threadlocal
----.project(1KB)
----src()
--------c3p0-config.xml(577B)
--------com()
----WebRoot()
--------WEB-INF()
--------index.jsp(829B)
--------META-INF()
----.settings()
--------org.eclipse.wst.jsdt.ui.superType.container(49B)
--------org.eclipse.wst.common.project.facet.core.xml(414B)
--------org.eclipse.jdt.core.prefs(364B)
--------org.eclipse.wst.jsdt.ui.superType.name(6B)
--------org.eclipse.wst.common.component(546B)
--------.jsdtscope(522B)
----.classpath(1KB)

网友评论

  • 不建议下载,没啥用,黑马的一个demo