开发者

Passing Request Object into Service Layer

In a spring mvc + spring core app, we have have a view layers, a facade, a service layer, a dao layer and a stored-proc based persistance layer.

The service layer is unaware of the clients that utilitize its methods. Is it fine 开发者_Go百科to propagate raw http requests into the service layer? Or is it bad practice and a violation of the loose coupling principles?

If it is, then what's a clean workaround?


It's hard to say without specifics, but whether it's bad practice or not depends if you care about coupling your service layer to the servlet API. In general, though, it would be better to keep your interface decoupled, and extract what you need from the request before passing it down to the service layer.

However, if your service layer really needs the request object (for whatever reason), then your coupling already exists, and adding it to the service layer is simply exposing that coupling (which is a good thing).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜