hello i am familiar with the mvc structure in the web layer,but i wonder how can i implement the mvc struction in the ejb layer. i can use the stateless session bean as the controller,but in the web layer,i can use the url to identify the different request,and path information,but in the ejb container,it seem like there isn't such machanism,how can the controller(session bean) reforward the different request?where can i find the sample code of the sessin bean controller?is it included within the petstore? thank you!
I think MVC is a design pattern for presentation layer. So you needn't implement in EJB, because EJB is in server layer or business logic layer. Actually, we can use "Front Controller", "Session Facade" and etc. design patterns in EJB. Perhaps the session bean you have meantioned is a "front controller".
David,<br />SCJP - 94% (2002-7-6)
Joined: Jan 14, 2002
thanks you are right,what i mean is to decouple the web tier and the ejb tier. in web tier,i can ONLY look up the session bean controller that is the facade of the business session bean models instead of looking up the business session beans individually,when the business tier is changed,i don't need to modify the web tier if only the session bean controller keep unchanged,the session bean controller is in charge to direct the different command that come from the web tier to the business session beasn acordingly,it makes the dcvelopement and modification convenient. do you have such an experience?and where can i find the sample code of such session bean controller?or can i get it from the petstore application? thank you!
"you are right,what i mean is to decouple the web tier and the ejb tier. in web tier,i can ONLY look up the session bean controller that is the facade of the business session bean models instead of looking up the business session beans individually,when the business tier is changed,i don't need to modify the web tier if only the session bean controller keep unchanged,the session bean controller is in charge to direct the different command that come from the web tier to the business session beasn acordingly,it makes the dcvelopement and modification convenient." You could use the Business Delegate pattern to decouple the Front controller and the Session by allowing it to handle the ejb-lookups. When changes are made in the session facade, the chages to be made in the Front controller will be reduced This might not be the best sulution. This is what I would do in this situation. Ebage SCJP SCEA
I'm not sure if I'm following this properly, so pardon me if what I'm about to say seems strange or unrelated... First, what we do in J2EE isn't truly MVC. HTTP isn't a viable mechanism for MVC because that's a pattern that requires 2-way asynchronous message flow. What you're probably thinking of is Model 2, which is the latest attempt at adapting MVC to work in an HTTP/J2EE environment. Just wanted to be more precise here since to adapt a mechanism it's first good to realize what you're working with. The purpose of a Controller in MVC is to provide a converter or adapter that translates the view input to the model and the model to the view display. It can be expected to be familiar with the detailed mechanics of the particular display system, so it's not very portable. The closest thing you'll normally see to controller logic in an EJB is if it works with XML. Session EJBs are often used as mediators between controllers (such as servlets or JSP helper classes) and Entity EJBs. Among their common usages may be seen the functions of presenting and managing collections of fine-grained EJBs, synopsizing to provide a coarse-grained EJB and presentation of composite objects made to provide a unitary view composed by matching up Entity EJBs for such things as giving a combined view of data from more than one database table (with corresponding Entity EJBs). Examples of a combined view might be the extraction of related items from tables that match 1-to-1 or pairing of parent-child (1-to-many) data items. Note that in this paragraph I'm using the terms "view" and "present" to refer to what the controller "sees", and not meaning actual visual presentation. I hope that helped!
Customer surveys are for companies who didn't pay proper attention to begin with.