EJB依赖于FacesContext是不好的设计吗? [英] Is it a bad design for a EJB to depend on FacesContext?
问题描述
context.getExternalContext()。getRequestLocale()
传递给EJB,而不是使用import和getCurrentInstance从内部更好EJB? import javax.faces.context.FacesContext;
FacesContext.getCurrentInstance()
(我是新的Web开发)
如果您将软件系统视为三层架构,那么 FacesContext
(它是JSF框架的一部分)属于应用层的表示层和 EJB
。
一般来说,较低层(应用程序)取决于较高层(Presentation),软件设计不好。它导致高耦合,低内聚力,因此总体上软件质量差。
总而言之,最好是通过参数传递值而不是访问 FacesContext
从 EJB
。
Would it be better, for example, to pass context.getExternalContext().getRequestLocale()
to the EJB by parameter, instead of using an import and getCurrentInstance from inside the EJB?
import javax.faces.context.FacesContext;
FacesContext.getCurrentInstance()
(I'm new to web development)
If you think of your software system as a three layer architecture then the FacesContext
(which is part of the JSF framework) belongs to the presentation layer and the EJB
to the application layer.
In general it's bad software design when a lower layer (application) depending on higher layer (Presentation). It leads to high coupling, low cohesion and therefore overall to poor software quality.
To sum it up, it would be better to pass the values by parameter instead of accessing the FacesContext
from a EJB
.
这篇关于EJB依赖于FacesContext是不好的设计吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!