• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to maintain SFSB ShoppingCart reference

 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
David Follow
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Newman Huang
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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).
reply
    Bookmark Topic Watch Topic
  • New Topic