A stateless session bean allows multiple clients to share a single instance. Clients may issue multiple requests to a stateless bean, but the bean does not keep track of any client-specific data.
What sorts of tasks can a stateless session bean perform on a client's behalf? A session bean (stateful or stateless) generally implements a business process. A business process is a series of tasks that conforms to a set of rules for a business enterprise. The session bean's job is to fulfill these steps and to make sure the process conforms to the rules. For example, a session bean may access a database in a read-only mode to supply certain information, such as items in a catalog. Or, the session bean could read company archive data looking for sales trends, popular items, or effective sales managers. Given certain data, a session bean can also perform some sort of conversion on that data. A currency converter can look up current conversion rates. A translator session bean can translate text from one language to another. All of these processes manipulate data, but the results of the manipulation are transient: they're simply returned to the client.
Session beans can also create permanent data. In the enterprise world, we call permanent data a business entity. Examples of business entities are customers, orders, and transactions. In general, a session bean that manipulates a business entity will not do so directly; it will make a request of an entity bean, which in turn oversees the creation or modification of a business entity.
Our first EJB is an example of a business process that takes data and provides a transformation. The input data and the resultant transformation are returned to the client without being stored. Since there's no need to save state, we use a stateless session bean. This example is conceptually simple; however, throughout its presentation, we explore design issues that will help us create far more complicated enterprise applications later. We will point out these design issues as we go along.
Design Guideline
13.59.204.181