免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 889 | 回复: 0
打印 上一主题 下一主题

J2EE design decisions [javaworld] [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-13 17:33 |只看该作者 |倒序浏览

J2EE design decisions
http://www.javaworld.com/javaworld/jw-01-2006/jw-0130-pojo.html
1.Business logic organization - 业务逻辑组织
Using a procedural design
非常简单的应用使用此方式,但随着业务规模的扩大,后续开发和维护会有问题.
Using an object-oriented design
业务逻辑层已经包含业务模型.
2.Encapsulating the business logic tier - 业务逻辑层封装
EJB session facade
使用Session Bean门面,粗粒度设计,但是依赖EJB容器.
POJO facade
使用POJO作为业务逻辑单元,是POJO facade提供服务的入口.
Exposed Domain Model pattern
譬如使用Spring管理所有的业务逻辑对象,通过spring进行引用.
3.Database access decisions - 持久层的设计
Using JDBC directly
费时费力,移植性差
Using iBATIS - addressed the problem of mapping between Java classes and SQL statements
完成了java类与sql的映射
to completely insulating the application from connections and prepared statements, iBATIS maps JavaBeans to SQL statements using XML descriptor files.
使用xml配置文件,把sql从java类中剥离出来.
iBATIS cannot address the overhead of developing and maintaining SQL or its lack of portability.
不能解决sql的维护和移植性的问题.

Using Spring's JDBC classes
使用了spring对jdbc的抽象,防止了jdbc的繁琐,代码可以更加优雅

Using a persistence framework
EJB 2
JDO
Hibernate

4.Concurrency in transactions - 并发事务控制

Handle concurrency in short transactions  短事务
Isolated database transactions 数据库事务隔离
Optimistic locking 乐观锁
Optimistic locking derives its name from the fact it assumes that concurrent updates are rare and that, instead of preventing them, the application detects and recovers from them.
An application can determine whether the UPDATE statement succeeded by checking the row count returned by PreparedStatement.executeUpdate(). If the row has been updated or deleted by another transaction, the application can roll back the transaction and start over.
Pessimistic locking 悲观锁
An alternative approach is to use pessimistic locking, which assumes that concurrent updates will occur and must be prevented.

Handle concurrency in long-running transactions 长事务
Optimistic Offline Lock pattern 乐观脱机锁
One option is to extend the optimistic locking mechanism described earlier and check in the final database transaction of the editing process that the data has not changed since it was first read. You can, for example, do this by using a version number column in the shared data's table. At the start of the editing process, the application stores the version number in the session state. Then, when the user saves their changes, the application makes sure that the saved version number matches the version number in the database

Pessimistic Offline Lock pattern 悲观脱机锁
The Pessimistic Offline Lock pattern handles concurrent updates across a sequence of database transactions by locking the shared data at the start of the editing process, which prevents other users from editing it. It is similar to the pessimistic locking mechanism described earlier except that the locks are implemented by the application rather than the database. Because only one user at a time is able to edit the shared data, they are guaranteed to be able to save their changes.  


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/13917/showart_74270.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP