aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes using stateful and stateless session bean together, what happens? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "using stateful and stateless session bean together, what happens?" Watch "using stateful and stateless session bean together, what happens?" New topic
Author

using stateful and stateless session bean together, what happens?

li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
I am using a session facade called controller class, but I can't decide what type it should be?


behind it are all stateless session beans, like searchManager class, etc

so must this controller be stateless too? or else all the stateless beans behind it will "turn" stateful !!??

How JEE handles this scenario? a stateful bean calls stateless beans

Many thanks !!
li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
and in such case, Can I say this controller class is a servlet?
li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
I seem to have made a mistake:

commonly, a servlet class should call a session facade to access beans

in my case, I put servlet and session facade as one class: controller

Is this definitely wrong??
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Definitely.
li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
Cameron Wallace McKenzie wrote:Definitely.


omg,iam going to fail
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

A front controller (Servlet) invokes a session facade (stateless session bean).

That's a very fundamental pattern and implementation.
li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
thanks, I am confused with one example solution, which is :

jsp pages --> controller --> stateless session beans


in such case, what should this controller be?

there is only one class between jsps and stateless session bean, what pattern might this better be?

thanks! I will change my name if you answer me

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Google "Front Controller" and you will find many discussions on this particular pattern.

Front Controller Design Pattern

The easiest way to implement this is to simply say you are using Sun's JSF framework. The JSF framework provides its own Front Controller, the FacesServlet. Just say your application will be using this Servlet as your front controller, and you're done.
li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
Cameron Wallace McKenzie wrote:Google "Front Controller" and you will find many discussions on this particular pattern.

Front Controller Design Pattern

The easiest way to implement this is to simply say you are using Sun's JSF framework. The JSF framework provides its own Front Controller, the FacesServlet. Just say your application will be using this Servlet as your front controller, and you're done.


so you mean, there must be a front controller (FacesServlet), and my controller class is then session facade .

Thanks a lot

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I'm worried that you have the idea of a command pattern and a controller pattern confused. I think you need to define what a controller is to you, and what its purpose is.

Based on the Command pattern [GoF], the Command and Controller Strategy suggests providing a generic interface to the helper components to which the controller may delegate responsibility, minimizing the coupling among these components (see "View Helper" on page 33 for more information on helper components). Adding to or changing the work that needs to be completed by these helpers does not require any changes to the interface between the controller and the helpers, but rather to the type and/or content of the commands. This provides a flexible and easily extensible mechanism for developers to add request handling behaviors.


You seem to be describing a scenario where a controller calls on GOF commands?



These quotes and images are from the following link:

Suns J2EE Core Design Patterns

li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
it's the sample solution from that famous author, I can't remember name

so what do you think his controller class is doing?

I can paste the whole image if you need.





[Thumbnail for controller.jpg]

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

It looks to me like the controller class is invoking a manager class.

Please quote your sources. If this is from an authors copyrighted work, posting it here may very well be a copyright violation.
sivan jai
Ranch Hand

Joined: Feb 24, 2010
Posts: 115
good discussion.

If the faces servlet is your front controller what if I need to have my own front controller? My question is if I start using JSF is my own front controller not relevant at all?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

One front controller is more than enough.

I have seen plenty of architects build frameworks around frameworks, and it's a mess.

I'm not sure of a business scenario where you'd capture a request with a front controller, and pass it to another front controller. You can always extend the FacesServlet to provide extra functionality to your front controller.
li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
Cameron Wallace McKenzie wrote:It looks to me like the controller class is invoking a manager class.

Please quote your sources. If this is from an authors copyrighted work, posting it here may very well be a copyright violation.


it's by Humphrey Sheil in his new SCEA guide book chapter nine

yes controller calls several manager classes, manager classes manage some entity classes.


I think, he omits servlet layer classes, coz less important, and in such case, controller is session facade

and it can't be a front controller becoz it's behind all jsp pages ,not in front.


what do you think?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

If the controller is a Session Facade, then why is it not marked with an EJB annotation like the Manager classes? That would indicate to me that it is not an EJB,and thus, not a Session EJB, and thus, not a Session Facade. Besides, an EJB doesn't take http requests. The controller would need to be implemented as some type of Java artifact that can be invoked through the http protocol, especially if it is accepting requests from a JSP.

li tiangong
Ranch Hand

Joined: Oct 18, 2009
Posts: 34
another diagram:

so understand it in this way: in Humphrey Sheil's diagram, controller is a servlet, it's not using service locator (like in this, don't know from where diagram) but dependency inject to talk to manager classes

if there is any pattern here, it's DI only



[Thumbnail for 34386160.jpg]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using stateful and stateless session bean together, what happens?