TAILIEUCHUNG - Design ejb design patterns phần 5

Hơn nữa, đoạn mã này là phức tạp và đòi hỏi xử lý lỗi tẻ nhạt (ClassCastExceptions, NamingExceptions, và như vậy). Nhân bản mã này trên tất cả các khách hàng chỉ đơn giản là một vụ lộn xộn. Thậm chí tệ hơn, một khi nhà được lấy ra, nó chỉ sử dụng một lần (để có được stub EJBObject). | Client-Side EJB Interaction Patterns 93 Furthermore this code is complex and requires tedious error handling ClassCastExceptions NamingExceptions and so on . Duplicating this code all over the clients is simply a messy affair. Even worse once the home is retrieved it is only used once to get the EJBObject stub . Performing a JNDI lookup every time an EJBHome is needed can be expensive for the following reasons Requires a network call if the JNDI server is on a different machine. If the client is not collocated on the same machine as the JNDI server then the call to JDNI will require a network call. This may occur for example in a clustered scenario where the Web server servlet engine is on a different box than the EJB server where the JNDI server is usually part of the EJB server. May require interprocess communication IPC if the JNDI server is on the same box. If the client is running on the same box as the EJB server but is not running within the same virtual machine VM then there is IPC overhead in looking up an EJBHome. Even if the client such as a servlet client is running within the same VM as the JNDI server looking up an EJBHome for every Web request can only hurt performance since an EJBHome never goes stale and can be reused for the lifetime of the client application. Imagine a highly trafficked Web site such as in which a particular page may be viewed about 500 times per minute. The performance overhead of looking up the same object 500 times for 500 different clients is significant and completely unnecessary. A better way is needed to look up an EJBHome one that allows lookup code to be abstracted and one that can reuse the same EJBHome instance throughout the lifetime of the client. Therefore Abstract EJBHome lookup code into a reusable EJBHomeFactory which can cache EJBHomes for the lifetime of a client application. An EJBHomeFactory is a plain Java class implemented as a singleton as in Figure . The factory encapsulates EJBHome .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.