aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes How to maintain SFSB ShoppingCart reference 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 "How to maintain SFSB ShoppingCart reference" Watch "How to maintain SFSB ShoppingCart reference" New topic
Author

How to maintain SFSB ShoppingCart reference

David Follow
Ranch Hand

Joined: Oct 16, 2001
Posts: 223
Hi all,

I know that the subject of shopping cart has been addressed in this forum many times already. However, I still want to discuss the issue of where to store the referent to the SFSB shopping cart.

Currently, I am thinking of
Action(web)/Command(Swing) -> BD -> Facade (SLSB) -> ShoppingCart (SFSB)

The point is, that my Facade will be stateless, but at one point it will have to store session data e.g. flights to be booked, in the stateful shopping cart. Therefore, the Facade will call create() on the ShoppingCart. However, I will have to save somehow and somewhere the reference (or handle) to the remote interface of the shopping cart and retrieve it later for further processing by passing it to the Facade methods.

Currently I can think of storing the SFSB reference in HttpSession and pass it to the Facade with each Facade method. But who will load it from HttpSession and pass it to the Facade? The BD? But I would like to reuse the BD for both kinds of clients (swing and web). Using the BD in the application client, it obviously does not have access to HttpSession. In that case, I would have to provide two BDs one for each kind of client...

Maybe I am thinking to complicated. What are your ideas and thoughts? How do you handle the SFSB shopping cart?

D.
[ October 08, 2006: Message edited by: David Follow ]

SCJP, SCEA
Ian Guedes Maia
Greenhorn

Joined: Aug 22, 2006
Posts: 4
Hi David.

If you need to store a SFSB reference in HttpSession, why would you use SFSB? Why not just maintaining user's session state using regular java classes in HttpSession?


Ian Guedes<br />Fortaleza - CE / Brazil
Newman Huang
Ranch Hand

Joined: Mar 31, 2003
Posts: 85
hi, David

as your describing, i think you meet the problem, that is using SLSB facade can not work smoothly with SFSB. it seems redundant putting SFSB reference in httpsession and passing back to the SLSB facade, right? my suggestion is to take a look at the code of petstore.

another question is whether it is appropriate to reuse the BD? i think the web BD and swing BD are different.


SCJP,SCJD,SCEA
David Follow
Ranch Hand

Joined: Oct 16, 2001
Posts: 223
Originally posted by Newman Huang:
it seems redundant putting SFSB reference in httpsession and passing back to the SLSB facade, right? my suggestion is to take a look at the code of petstore.

another question is whether it is appropriate to reuse the BD? i think the web BD and swing BD are different.


Newman,

yes, it seems strange to pass the SFSB reference to the SLSB Facade from the presentation tier. But HttpSession is the only place where I could store the SFSB reference (or probably better its handle). How does PetStore solve the problem? Can you point me to the concrete PetStore classes that do that? I found the PetStore ShoppingCart component but nothing that references or instantiates that component.

Why do you think we will need different BDs per client? Isn't that the whole point that we have a business-oriented BD that is there to use by any kind of client? What does a swing BD do different from a web BD?

D.
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
I think we all agree that the Shopping Cart should be implemented as SFSB. It means that we store state in the business tier. Do we want to store references to this state information outside the business tier? I would say � No. My conclusion is therefore to implement the Fa�ade as SFSB and then everything falls into place.

From scalability point of view - if we are already implementing the Shopping Cart as SFSB, making the Fa�ade SFSB as well, only doubles the number of SFSBs in the system. The two situations have the same order of magnitude O(n) = O(2*n).

Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Newman Huang
Ranch Hand

Joined: Mar 31, 2003
Posts: 85

Can you point me to the concrete PetStore classes that do that? I found the PetStore ShoppingCart component but nothing that references or instantiates that component.


please trace the code by following:
1.http get/post
2.MainServlet handle the request
3.MainServlet delegates to RequestProcessor for handling
4.RequestProcessor delegates to HTMLAction to parse the request and return Event
5.RequestProcessor delegates to ShoppingWebController to handle Event
6.ShoppingWebController gets ShoppingControllerLocal(SFSB) from DefaultComponentManager, which gets the ShoppingControllerLocal from httpsession
7.ShoppingControllerLocal delegates StateMachine to handle Event
8.StateMachine calls EJBAction to handle business logic, EJBAction can get attributes from its StateMachine member variable to obtain the operation data such as VO,TO, and ShoppingCart etc
9.The handling result is passed back to MainServlet, and runs next steps, such as displaying


Why do you think we will need different BDs per client? Isn't that the whole point that we have a business-oriented BD that is there to use by any kind of client? What does a swing BD do different from a web BD?

The handle mechanism in swing client could be different with what does in web client. It depends on your design. For example, different facades for different clients. BD is proxy for business service, it depends on what services it serves as.
David Follow
Ranch Hand

Joined: Oct 16, 2001
Posts: 223
Originally posted by Dan Drillich:
Do we want to store references to this state information outside the business tier? I would say � No. My conclusion is therefore to implement the Fa�ade as SFSB and then everything falls into place.


Dan,

I don't understand when you say that you don't want to store the reference to this state information outside of the business tier. Do you mean the shopping cart state itself or the reference to the cart? I guess you must store the reference or handle to the SFSB shopping cart outside of the business tier (e.g. HttpSession) otherwise you will lose the handle to the SFSB.

D.
David Follow
Ranch Hand

Joined: Oct 16, 2001
Posts: 223
Newman,

thanks for your detailed description.
I looked into the PetStore Shopping Cart implementation and I think they got a bit carried away with all those SFSB. If I countered correctly, they use three (!!!) SFSB just to implement thr shopping cart. I guess this is a big waste of resources. It may be a nice design but from my point of view far away from reality. Nobody would accept three SFSB for the implementation of a rather simple shopping cart.

Waht is your thought?

D.
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
David,

I don't understand when you say that you don't want to store the reference to this state information outside of the business tier. Do you mean the shopping cart state itself or the reference to the cart? I guess you must store the reference or handle to the SFSB shopping cart outside of the business tier (e.g. HttpSession) otherwise you will lose the handle to the SFSB.


You are right! I got carried away.

Regards,
Dan
Newman Huang
Ranch Hand

Joined: Mar 31, 2003
Posts: 85

Nobody would accept three SFSB for the implementation of a rather simple shopping cart.
Waht is your thought?


yes, judging by performance, you are right. SFSB has been scolded too much.
in Core J2EE patterns, the author reclaims a bit reputation for it. you can take a look at chapter7(session facade).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to maintain SFSB ShoppingCart reference