Expert one-on-one J2EE Design and Development phần 5

Nếu các đối tượng kinh doanh có khả năng có thể gây ra lỗi nghiêm trọng, nhận được chúng ra khỏi quá trình "khả năng đàn hồi có thể lớn hơn, đặc biệt là nếu máy chủ J2EE cung cấp định tuyến phức tạp của các cuộc gọi phiên đậu không quốc tịch. WebLogic, ví dụ, có thể thử lại các cuộc gọi không thành công trên đậu kỳ họp | Data Access in J2EE Applications JDBC access from custom tags is superficially appealing because it s efficient and convenient. Consider the following JSP fragment from the JSP Standard Tag Library specification which transfers an amount from one account to another using two SQL updates. We ll discuss the JSP STL Expression Language in Chapter 13. The syntax is used to access variables already defined on the page sql transaction datasource datasource sql update UPDATE account SET Balance Balance - WHERE accountNo sql param value transferAmount1 sql param value accountFrom sql update sql update UPDATE account SET Balance Balance WHERE accountNo sql param value transferAmount sql value accountTol sql update sql transaction Now let s consider some of the design principles such a JSP violates and the problems that it is likely to produce o The JSP source fails to reflect the structure of the dynamic page it will generate. The 16 lines of code shown above are certain to be the most important part of a JSP that contains them yet they generate no content. o Distributed applications only Reduced deployment flexibility. Now that the web tier is dependent on the database it needs to be able to communicate with the database not just the EJB tier of the application. o Broken error handling. By the time we encounter any errors such as failure to communicate with the database we re committed to rendering one particular view. At best we ll end up on a generic error page at worst the buffer will have been flushed before the error was encountered and we ll get a broken page. o The need to perform transaction management in a JSP to ensure that updates occur together or not at all. Transaction management should be the responsibility of middle tier objects. o Subversion of the principle that business logic belongs in the middle tier. There s no supporting layer of middle tier objects. There s no way to expose the business logic contained in this page to non-web clients or

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
261    95    3    08-06-2024
24    75    2    08-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.