锁定老帖子 主题:JSF+EJB3架构实际项目
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-02-23
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-02-23
seam已经为你做好一切了,嘿嘿
|
|
返回顶楼 | |
发表时间:2008-02-23
各位从EJB设计的角度分析下,这样行不行。。至于seam,它只是这两者的一个粘合剂。还是想先从JavaEE5的技术角度来完成一个项目。
|
|
返回顶楼 | |
发表时间:2008-02-27
基本的结构是没错的,我不是很明白“显示对象”是用来做什么的
|
|
返回顶楼 | |
发表时间: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. |
|
返回顶楼 | |
发表时间:2008-02-28
整个结构没有什么问题,挺清楚的,基本是现在大家都认可的一种方式,不过在实施的时候还需要把握的准确一些,有些问题需要注意,比如层次之间的清晰,如界面层的东西不要传递到后面去。还有就是JPA的设计了,很多基于类似于JPA的设计容易受先前的一些影响,比如走着走着就走向以前的SQL老路,等等这些。
|
|
返回顶楼 | |
发表时间: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的优异性能进行运行。 |
|
返回顶楼 | |
发表时间: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 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. 我说的显示对象就是类似Struts的ActionFrom的东西。 很是受你的启发。我也一直觉得这样设计太过复杂,而且走入了SSH的圈套,大量的Bean的创建,属性挎贝执行效率会受影响。我目前新的设计见附图。也像你说的:Facelets --> ManagedBean -->EJB3 SessionBean(业务层) -->JPA (持久层) ---> DataBase(EIS层).这样就把Dao层去了,把VO和PO合并了,但感觉显示层的显示对象还是需要的,要不然有些数据在页面显示会有麻烦(robbin很早的一个帖子就讨论过这个问题)。请指点。。。 |
|
返回顶楼 | |
发表时间:2008-03-03
"但感觉显示层的显示对象还是需要的,要不然有些数据在页面显示会有麻烦" <div class="light col input-field"> media: Pojo(+annotation),entity bean name,comments,format: properties of Entity bean "Media"
tapeFormatList: List<SelectItem>
2) JSF managed bean examples:
public class MediaBean extends CmmManagedBean
3) Entity Bean
package uk.co.ondemand.cmm.service.persistence;
public class Media extends GenericEntity
@Column(name = "COMMENTS")
@JoinColumn(name = "FORMAT", referencedColumnName = "ID")
@Transient private List foldersList; //use "Transient" annotion for additional fields not persistent,but used in JSF component value binding for carrying data.
.....
4) You also can use converters for some data type conversion between pages to models
faces-config.xml ... <converter> <converter-for-class>java.lang.Boolean</converter-for-class> <managed-bean>
Hope this is helpful.
|
|
返回顶楼 | |
发表时间:2008-03-04
呵呵,我对JSF不是很了解,只是用JSF做过两个项目,以前都是用JSF+Spring+Hibernate。
如果用你说的PO一对象从持久层传到页面,就有一个这样的问题,我做一个员工的查询,我的员工PO类中只有入职时间,我现在要做个组件条件查询在某个时间段入职的员工,这里是不是得再构造个类似ActionForm对象了。请指教。。 |
|
返回顶楼 | |