Java Reference
In-Depth Information
We'll first describe the example use case and then explain why the concurrency
mechanisms we examined in chapter 12 cannot be used to handle the scenario of
two users editing the same data simultaneously.
13.1.1
An example of an edit-style use case
The Acknowledge Order use case, a typical edit-style use case, describes how the
restaurant acknowledges receipt of an order by either accepting or rejecting it.
This use case has the following specification:
The system displays an order that has been sent to the restaurant. The restau-
rant's order taker accepts or rejects the order. The system displays a confirma-
tion page. The restaurant's order taker confirms that she accepts or rejects the
order. The system changes the state of the order to ACCEPTED or REJECTED .
The normal usage scenario for this use case consists of the user selecting the order,
accepting it, and confirming that he wants to accept the order. Since this is a web
application, each step results in the user's browser sending an HTTP request to the
application. The application processes the request, which involves accessing the
database, and then generates the HTML for the next page. Figure 13.1 shows these
requests and the SQL statements that each one executes.
The application handles the first request, which is sent when the user begins the
use case, by executing a SQL SELECT statement that retrieves the order. The second
request, which is sent when the user accepts or rejects the order, is handled by the
presentation tier—perhaps within the browser if the application has an Ajax UI , for
example—and does not result in any SQL statements being executed. The applica-
tion handles the third request, which is sent when the user confirms that he wants
to accept or reject the order, by executing an UPDATE statement that changes the
state of the order to either ACCEPTED or REJECTED and updates the notes.
13.1.2
Handling concurrency in an edit-style use case
Because the Food to Go application is a multiuser system, multiple users could
attempt to update the same order simultaneously. For example, while the restau-
rant order taker reviews the order displayed on the Acknowledge Order screen,
another user could try to cancel the order. The application must handle this sce-
nario and either prevent the other user from canceling the order or prevent the
restaurant order taker from accepting a canceled order. Otherwise, the restaurant
would prepare an order that had been canceled.
 
 
 
 
 
Search WWH ::




Custom Search