Java Reference
In-Depth Information
which consists of the
ModifyOrderService
,
ModifyOrderServiceImpl
(which imple-
ments the
ModifyOrderService
interface), and the classes that it calls.In addition
to the
ModifyOrderService
and
ModifyOrderServiceImpl
, the design consists of
these other classes:
■
OrderRepository
loads the
Order
.
■
PendingOrderRepository
creates, loads, and deletes the
PendingOrder
.
■
LockManager
maintains the locks in the database.
■
PendingOrder
stores the changes made to the
Order
.
■
Order
is the order being edited.
ModifyOrderResult
is returned by the
ModifyOrderService
.
■
There are lots of details of the business logic that you do not need to know about
to understand how the Pessimistic Offline Lock pattern works, so we'll focus just
on the
ModifyOrderService
class and how it interacts with the lock manager. Check
out the online source code if you want to see the details of the other classes.
ModifyOrderService
is an interface that specifies the methods that can be invoked
by the
POJO
façade or the presentation tier:
public interface ModifyOrderService {
public ModifyOrderServiceResult getOrderToModify(String caller,
String orderId);
public ModifyOrderServiceResult updateDeliveryInfo(
String caller, String orderId, String pendingOrderId,
Address deliveryAddress, Date deliveryTime);
public ModifyOrderServiceResult updateQuantities(String caller,
String orderId, String pendingOrderId, int[] quantities)
throws InvalidPendingOrderStateException;
public ModifyOrderServiceResult saveChangesToOrder(
String caller, String orderId, String pendingOrderId);
public ModifyOrderServiceResult cancelModifyOrder(
String caller, String orderId, String pendingOrderId);
}
Each method has a caller parameter, which is used as the lock owner. It could be
the
HttpSession
ID
or the user
ID
. The other method parameters include the
ID
s
of orders and pending orders as well as values entered by the user, such as the
delivery time and the line item quantities.
The
ModifyOrderService
interface is implemented by the
ModifyOrderServi-
ceImpl
class, which is shown in listing 13.4.
ModifyOrderServiceImpl
fulfills
Search WWH ::
Custom Search