tailieunhanh - Patterns in JavaTM, Volume 3 Java Enterprise Java Enterprise Design Patterns phần 3
Một đối tượng trong vai trò của người quản lý giao dịch thao túng các trường hợp của các lớp khác tham gia trong một giao dịch. Trước khi làm cái gì đó sẽ thay đổi trạng thái của một đối tượng mà nó thao tác, quản lý giao dịch sẽ sử dụng một thể hiện của lớp khác để lưu các trạng thái ban đầu của đối tượng. | 92 Chapter Five through an interface they need not be aware of the fact that they are calling the methods of a Stub object that is a proxy for the Callee object rather than the Callee object itself. The Stub object encapsulates the details of how calls to the Callee object are made and its location . direct calls to an object or calls through a remote proxy . These details are transparent to Caller objects. RemotelF. Objects that have methods that may be called by remote objects implement an interface that is in this role. A method can be called remotely if and only if it declared by a RemoteiF interface that its class implements. Stub. Classes in this role implement a RemotelF interface. Every RemoteiF interface has a corresponding Stub class. A Stub object is a remote proxy for an object in the Callee role whose methods can be called remotely. Stub classes implement the methods of a RemoteiF interface by passing on the fact that the method was called and the values of its parameters to a Connection object. They assemble information identifying the Callee object the method being called and the values of the arguments into a message. On the other end of the connection part of the message is interpreted by a CallDispatcher object and the rest by a Skeleton object. When the remote call returns the Skeleton object sends a response back to the Stub object that contains the returned value or the exception thrown. The Stub object interprets the message by returning the value or throwing the exception. implementations of object request brokers include a mechanism for automatically creating Stub classes. Connection. Classes in this role are responsible for the transport of messages between the environment of a remote caller and the environment of the callee. CallDispatcher. Instances of classes in this role receive messages through a Connection object from a remote Stub object. They pass each message to an instance of an appropriate Skeleton class. Classes in this role
đang nạp các trang xem trước