Using @Stateless
26 June 2008Stateless session beans are those, who do not keep track of the information that is passed from one method call to another. Thus, they don’t have internal state and each invocation of a stateless business method is independent of its previous invocation. These beans are simple to manage for the container. For example: tax calculation is a business task and we can have a bean for that. It will simply calculate the tax for an employee. It can be a stateless session bean since each time we call it, we need it to calculate tax of a different employee which has nothing to do with the previous results.
An example is presented below:
import javax.ejb.Stateless.*; @Stateless(name="CalculateEJB") public class CalculateEJBBean implements CalculateEJB { int value = 0; public String incrementValue() { value++; return "value incremented by 1"; } }
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Using @Stateless