• 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

Server Session pattern

 
Ranch Hand
Posts: 1419
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In his book about patterns for enterprise architecture, Martin Fowler describes the "Server Session" pattern -- a strategy in which session state is stored on the server instead of on the client.

In the Java PetStore application, for example, the Shopping Cart is implemented as a stateful session bean on the application server.

The Shopping Cart is associated with the end user's web browser, but the immediate client of the EJB tier is the Web tier. That being the case, what mechanism maintains the association between individual Shopping Cart EJBs with individual clients of the web tier?

That is to say, when the web tier gets a request from the user to add to his shopping cart, how does the web tier (or other intermediary) look up the Shopping Cart stateful session bean associated with that particular user? Which component maintains the association between customer userIds and shopping cart stateful session EJB handles?
 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using JSP or a framework, use the built in session capability.

If not, you'll need to build a session capability, probably using either cookies or URL rewriting.
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Warren, Frank seems to be asking about "stateful session beans" if he wants to use them to maintain session. Your suggestion seems to point to use web teir sessions...

The question is "how web tier knows the session identifier for the corresponding stateful session bean?". I guess this question might better get answered in the EJB forum but to give my 2 cents, I remember I read it somewhere that web tier has to 'remember' the handle (EJBHandle) to the stateful session bean in order to query back to appropriate stateful session bean in this case.

Thanks
Maulin
 
Frank Silbermann
Ranch Hand
Posts: 1419
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Maulin Vasavada:
Warren, Frank seems to be asking about "stateful session beans" if he wants to use them to maintain session. Your suggestion seems to point to use web tier sessions...

The question is "how web tier knows the session identifier for the corresponding stateful session bean?". I guess this question might better get answered in the EJB forum but to give my 2 cents, I remember I read it somewhere that web tier has to 'remember' the handle (EJBHandle) to the stateful session bean in order to query back to appropriate stateful session bean in this case.



Right, that was the question. Does the framework that comes with the Pet Store Application map have a facility to automatically map users to stateful session bean handles?

If not, would the web application put a stateful session bean handle in each user's web tier state? (It seems to me that this would destroy an important benefit of keeping state in the EJB tier -- the ease of stateless webserver clustering.)

I suppose that the EJB tier can keep a map of userIDs to shopping cart stateful session beans, but oddly enough, the architecture/design document for the Pet Store application never discussed this issue.
 
reply
    Bookmark Topic Watch Topic
  • New Topic