Am I correct in using the design pattern as below?
I am developing an web application with multiple layers using nhibernate as ORM. My layer structure is as follow
with the above layers, the classes and interfaces are placed as below diagram.
sample of code for the above classes.
From the UI layer, I create the session as request per session and inject into service layer with the help of class constructor. Then set the session of repository with a help of a method.
I can directly set the session for repository using with a constructor as same as I have done for service class. If I do so, I will not have the control over it under the service layer. Also there is a future extension plan for using a **webservice** layer.
** A question arise here, In repository I need to set the session first. Otherwise all other methods would not function. To resolve this, in each methods, I need to verify weather the session is set or not. This is not looking to me as correct way. Any suggestion on this as well please.
** Is the above design correct? Or need changes?
Muneer Shaheed, Jan 06, 2013