tailieunhanh - Patterns in JavaTM, Volume 3 Java Enterprise Java Enterprise Design Patterns phần 9

Khôi phục trạng thái của đối tượng tham gia từ những thông tin * gói gọn trong đối tượng nhất định. * Các đối tượng nhất định phải được trả lại bằng phương pháp captureState * đối tượng này. * / Public void restoreState (SnapshotIF nhà nước); / ** * Ngày phát hành một khóa thu được trước đó. | interface PersistablelF BusinessClassl BusinessClass2 persists persists persistenceLayer FIGURE Persistence Layer pattern. 392 Database Patterns 393 this one-to-one relationship. Alternatively there may be one or a small number of classes in the role that implement multiple interfaces and so are responsible for managing the persistence of instances of multiple classes. You usually see this organization when the code that implements the persistence logic is generated at runtime by a code generator. Using a code generator to generate the persistence code can be a big savings in programmer time. However automatically generated code tends not to be as well optimized as code written by a skilled programmer. TransactionManagerlF. Interfaces in this role declare methods that are used to commit or abort transactions. TransactionManagerImpl. Classes in this role implement the TransactionManagerIF interface. PersistenceManager. Classes in this role define methods that are responsible for creating and returning objects that implement the BusinessClasslPersisterlmpl BusinessClass2Persister-Impl . and TransactionManagerIF interfaces. If more than one type of persistent storage is supported then the classes methods are also responsible for ensuring that the objects they return are appropriate for the type of persistent storage being used. CONSEQUENCES If the underlying technology used to persist an application changes then only the persistence layer needs to change. For example an application that is initially developed to use a relational database may be changed to use an object-oriented database or a data cube. The underlying persistence schema can be changed without modifying any part of an application outside of its persistence layer. The logical complexities of working with the underlying database are hidden by the persistence layer from the rest of the application. For example most databases require a different call or command to store a new object than to update the

TỪ KHÓA LIÊN QUAN