In Java BluePrint PetStore Application shopping cart was implemented as SFSB.
"The shopping cart module implementation is a straightforward stateful session bean,
which maintains a collection of CartItem objects in a private HashMap.
EJB-tier components may access the shopping cart module directly. The Web
tier maintains a reference to the EJB-tier controller in an HttpSession attribute.
The EJB-tier controller’s method getShoppingClientFacade returns a reference to
a ShoppingClientFacadeLocal interface. The shopping client facade’s
getShoppingCart method returns the current session’s shopping cart."
And I'm going to implement my shopping cart in the same way.
But! I wonder if this decision can be applied in clustered environment
I mean situation when there are two or more hosts with installed web server and application server on each and load balancer.
Please help guys! It's very important for my SCEA assignment.
The J2EE specification does not require support for clustering so I don't think it is within the scope of the exam.
Even if it was, most J2EE container provide clustering and failover support for SFSBs. For the purpose of the assignment, you may choose to make an 'assumption' that the container will support clustering if needed.
In WebSphere for example, you can configure failover for an SFSB at the module, application or entire server level. WebSphere uses a so called Data Replication Service to replicate the session data among cluster members. If a member fails, another member of the cluster picks up the request and retrieves data from the shared repository. Depending on the container you choose to use, there are quite a few design, deployment and configuration considerations will apply to make the failover work.