aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Architecture of presentation and business layer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Architecture of presentation and business layer" Watch "Architecture of presentation and business layer" New topic
Author

Architecture of presentation and business layer

Rudolf Schmidt
Greenhorn

Joined: Sep 05, 2001
Posts: 10
Hi,
in my ejb system the controller (a servlet) finds out what to do(from request "todo"-parameter) and looks up an appropiate session bean (business logic, thats implements the command pattern, which means that the controller calls the "execute"-Method of the session bean). I am not sure what the return value from business logic ("execute"-Method) should look like to show the controller how presentation should be generated. As I want to avoid JSPs in favor of XML/XSL technology maybe business logic should return some kind of xml-document. Sometimes presentation consists of a static html file, so in these cases "execute"-Method must return a URL.
Does anyone have suggestions concerning coupling my business and presentation layer? Whats the "best" return value (what kind of xml-object could I return, how should the controller servlet process it?)
Another question is, if i should include another layer between the session beans (session facade) and the controller servlet (A layer with Command-Objects that use the session beans)?
Thanks in advance
Rudolf Schmidt
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Originally posted by Rudolf Schmidt:
Hi,
in my ejb system the controller (a servlet) finds out what to do(from request "todo"-parameter) and looks up an appropiate session bean (business logic, thats implements the command pattern, which means that the controller calls the "execute"-Method of the session bean). I am not sure what the return value from business logic ("execute"-Method) should look like to show the controller how presentation should be generated. As I want to avoid JSPs in favor of XML/XSL technology maybe business logic should return some kind of xml-document. Sometimes presentation consists of a static html file, so in these cases "execute"-Method must return a URL.
Does anyone have suggestions concerning coupling my business and presentation layer? Whats the "best" return value (what kind of xml-object could I return, how should the controller servlet process it?)
Another question is, if i should include another layer between the session beans (session facade) and the controller servlet (A layer with Command-Objects that use the session beans)?
Thanks in advance
Rudolf Schmidt

Why not always return an object that responds to a message "void render(HttpRequest req,HttpResponse resp)". Their can be two types of renderers:
(1) "Static" renderers forward to a URL or redirect to a URL.
(2) "Dynamic" renderers place the XML document that they contain onto the response output and/or invoke XSLT on it.
Kyle

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Rudolf Schmidt
Greenhorn

Joined: Sep 05, 2001
Posts: 10
Hi,
thanks for your answer. In the meantime I decided to put another layer between the controller servlet and the EJB session beans which is build of plain java-objects with "execute"-method. Kyle, I have two questions concerning your suggestions. First, if I understand you right, that object I return has to implement some kind of interface with a "render"-Method. As this object knows how to render itself, the controller first "executes" the object and then calls its "render"-Method to generate the appropiate output? Second question is concerning my architecture. I want to use the additional layer between controller servlet and session beans to avoid to much calls to the ejb container. The commands should make these calls only if needed. Is it acceptable that the commands and the "render"-Objects reside outside of the ejb-Container as they not EJBs even so they have a lot of work to do? Do I have to pool the command-objects in the controller-servlet or is one object of each enough as the servlet is multi-threaded? (oops, this was the third question).
Thanks in advance
Rudolf Schmidt
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Rudolf,
Yes, it's totally fine that those objects lie outside of the EJB container. The kind of thing you're doing (finding and invoking commands and then rendering output) is NOT business-layer logic. It's controller-layer and presentation-layer logic, so executing it in the servlet engine is totally fine.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
As to pooling -- it's probably easiest to start off NOT pooling the command and "renderer" objects first -- just create a new set of them for every invocation of the servlet methods. If you find you have a performance problem later THEN start pooling them.
Remember Beck's two rules of code optimization:
(1) Don't.
(2) Not yet.
Only optimize (pooling is an optimization) when you actually FIND a performance problem. Otherwise you're making a guess that will probably prove to be wrong -- leading you to waste your time. In XP terms "do the simplest thing that could work".
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Architecture of presentation and business layer