日期:2014-05-16  浏览次数:20460 次

JSF+EJB3架构实际项目
想用JSF1.2+EJB3做个项目,先画了个架构图,拿上来让各位指点指点,有何不妥之处。。
1 楼 jones 2008-02-23  
seam已经为你做好一切了,嘿嘿
2 楼 qiujy 2008-02-23  
各位从EJB设计的角度分析下,这样行不行。。至于seam,它只是这两者的一个粘合剂。还是想先从JavaEE5的技术角度来完成一个项目。
3 楼 elfer 2008-02-27  
基本的结构是没错的,我不是很明白“显示对象”是用来做什么的
4 楼 fxy1949 2008-02-27  
In my point of view,this structure is not so good. In your pattern, you don't benifit a lot from EJB3 and JSF. It's just the same like using struts1, spring, hibernate.

The main reasons are as following:

1) “显示对象”(Is it like actionForm in Struts1?), VO and PO are not needed any more,and use POJOs(+Annotation) as EJB3 entity Bean,which could also be used as VO,and be passed to web layer.In JSF "managed beans" and JSPs( or xhtml),use these beans as JSf compoment value binding objects.

In some cases, we need add some wrapper classes which may wrap several POJOs(EJB3 entity beans) for conmunication between web layer and business logic layer.

2) In EJB3 Session Bean,"EntityManger" is used for data handling. You will soon find out that DAO layer seems unnecessary. Consider no DAO layer first,add it when absolutely needed in case very complex business logic.


In my previous project using JSF+EJB,put it simply,the pattern is "Facelets--> .xhtml--> managedBean-->EJB Session Bean--> EJB3 Entity Bean -> database".

we use POJOs(+some wrapper classes) 1)for page component binding(in jsp or .xhtml); 2)for data transfer(as VO)between layers;and 3)for data persistence(as PO). This dramatically reduces the code for data conversion.

5 楼 w_y_g 2008-02-28  
整个结构没有什么问题,挺清楚的,基本是现在大家都认可的一种方式,不过在实施的时候还需要把握的准确一些,有些问题需要注意,比如层次之间的清晰,如界面层的东西不要传递到后面去。还有就是JPA的设计了,很多基于类似于JPA的设计容易受先前的一些影响,比如走着走着就走向以前的SQL老路,等等这些。
6 楼 w_y_g 2008-02-28  
补充一点,这些年大家对EJB都不是非常关注,大家的注意力都被吸引到了Spring和Hibernate,我自己开发的一点感触,其实EJB本身还是很优秀,只是对于开发而言不太具有亲和力,写了不长的业务代码,但是一个Deploy就要等半天,所以做着做着容易丧失耐性。

最近有个想法,不过没有时间去做,因为spring和hibernate从功能上来讲,和EJB没有太大的差别,除却AOP外,spring的功能与EJB Stateless Session一样,Hibernate和CMP一样,由于这些技术都基于配置,而且基本的参数类型也比较相似,所以可以使用spring,hibernate进行开发,用EJB运行,spring和hibernate的配置文件是可以转换为EJB配置的,这样一方面可以利用spring和hibernate进行便捷的开发,同时还可以利用EJB的优异性能进行运行。
7 楼 qiujy 2008-03-02  
fxy1949 写道
In my point of view,this structure is not so good. In your pattern, you don't benifit a lot from EJB3 and JSF. It's just the same like using struts1, spring, hibernate.

The main reasons are as following:

1) “显示对象”(Is it like actionForm in Struts1?), VO and PO are not needed any more,and use POJOs(+Annotation) as EJB3 entity Bean,which could also be used as VO,and be passed to web layer.In JSF "managed beans" and JSPs( or xhtml),use these beans as JSf compoment value binding objects.

In some cases, we need add some wrapper classes which may wrap several POJOs(EJB3 entity beans) for conmunication between web layer and business logic layer.

2) In EJB3 Session Bean,"EntityManger" is used for data handling. You will soon find out that DAO layer seems unnecessary. Consider no DAO layer first,add it when absolutely needed in case very complex business l