session bean and entity bean can be used to handle business logic, what situations will we use a Stateful Session Bean to handle business logic ? what situations stateless session bean? what situations entity bean? please help to clear them [ February 08, 2003: Message edited by: Timber Lee ]
what situations will we use a Stateful Session Bean to handle business logic ?
Stateful Session Bean should be used if you need to store a conversional state with the user. The typical scenario is the a shopping cart - the user puts the items into the cart one after the other and check out at the end. The Shopping card Stateful Session Bean stores the items that the user has chosen and encapsulates the business logic of calculating the order price, discounts etc. The main problem of the Stateful Session Beans is that they are more "ressource hungry" than the stateless session beans, since one Stateful Session Bean can serve only one client.
what situations stateless session bean?
Stateless Session Bean can be used if there is no conversional state with the user. One typical usage of the Stateless Session Bean would be a canceling the order: The user enter the order number and clicks on cancel, the code calls "cancel" method on a Stateless Session Bean and passes the order number as a parameter - everything that the bean needs to know about the request from the user must be passed as a parameter. One Stateless Session Bean can serve requests for more than one client which makes them more scalable.
what situations entity bean?
Entity beans should be used only from the stateless or the stateful session beans (one can use them in the presentation tier, but this creates usually a performance bottleneck). Entity beans are optional - their purpose is representing the persistent data, caching and storage manupulation. They should implement the storage logic - the business logic should be encapsulates in the session beans.
posted 17 years ago
Hi, Dragan Milic: thanks for your explanation, it is good for us to understanding. stateless bean , stateful bean and entity bean can be used for implementing business logic, as far as implementing business logic, what situation should we use stateless bean ? what situation stateful bean ? what situation entity bean ?
Hello ! Consider this very forum. A "search" is done by anyone without login too. We can use a stateless bean for this. But for posting a message, a state needs to be preserved.. like posting message under which forum, name of forum, which user posting it etc. we will choose a stateful bean here. A "Message" can be an Entity bean, so can "Forum". Hope this helps. The above explaination will make more sense to you now. Read it again. Leena