Java Reference
In-Depth Information
3.1. Getting to know session beans
A typical enterprise application will have numerous business activities or processes. For
example, the ActionBazaar application has processes like creating a user, adding an item
for auctioning, bidding for an item, ordering an item, and many more. Session beans are
used to encapsulate the business logic for each process. To best understand session beans,
you have to first understand the concept of a session.
The theory behind session beans centers on the idea that each request by a client to com-
plete a distinct business process is completed in a session. So what is a session? For an
example of a session, you can look to Microsoft's Remote Desktop. With Remote Desktop,
you can establish a connection to a remote machine which you can then control. You get to
see the desktop as if you were sitting right in front of the machine. You can access volumes
on the remote computer, launch applications, and, if the machine is on a separate network,
access resources available only on that network. When you're finished with the session you
disconnect to terminate it. In this case, your local computer is the client and the remote
computer is the server. Simply put, a session is a connection between a client and a server
that lasts a finite amount of time.
Not all sessions are equal. Sessions last for different durations with some being short and
others long. Instead of the remote desktop example, let's take a look at day-to-day conver-
sations. A conversation can be thought of as a form of a session between two people. A
short conversation would be a simple question and response to a stranger about the current
time: “What time is it?” “It's noon.” A longer conversation would be a discussion between
two friends as they banter about a basketball game. In the short conversation, the conver-
sation ends once the person responds with the time. You can categorize these two conver-
sations as stateless and stateful sessions, respectively—conveniently corresponding to ses-
sion bean types we'll discuss soon.
The concept of stateless and stateful sessions is seen throughout software development. In
the ActionBazaar application, some application processes are stateful whereas others are
stateless. For example, registering a new bidder involves multiple steps as the person sets
up an account, sets a password, and creates a profile. Bidding on an item is an example of
a stateless process. The request includes the user ID, item number, and amount. The server
responds with either a success or failure. This all happens in one step.
Search WWH ::




Custom Search