Designing Enterprise Applicationswith the J2EETM Platform 2nd phần 5

Tham khảo tài liệu 'designing enterprise applicationswith the j2eetm platform 2nd phần 5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | MESSAGE-DRIVEN BEANS 155 grate enterprise beans with packages and legacy applications. Chapter 6 discusses this approach further. When you want the message delivery to drive other events in the system. For example workflow steps can be based on the mere fact of message delivery or they can be based on the message content. When you want to create message selectors. A message selector is designed to take on only specific messages thus making it possible to use message-driven beans as triggers. Example Invoice Message-Driven Bean Code Example shows a message-driven bean that updates purchase orders based on invoice information received in a JMS message. The message-driven bean listens for JMS messages containing invoice data. When it receives a message its onMessage method extracts the invoice data from the message text. In this example the data has been encoded in XML which is parsed and then used to process an invoice. public class InvoiceMDB implements MessageDrivenBean MessageListener public void onMessage Message msg try String msgTxt TextMessage msg .getText Invoice invoice msgText do further processing catch . handle exceptions Code Example Message-Driven Bean Example 156 CHAPTER 5 THE ENTERPRISE JAVABEANS TIER Design Guidelines While you are free to write your application and enterprise bean code according to your own needs we do recommend certain guidelines. Keep the code in enterprise beans as client-neutral as possible. Enterprise beans are meant to contain business logic that can be used by many client types. Methods in enterprise beans that serve only one client type make any logic within that method inaccessible to other client types. Code that is specific for a particular client type belongs with the software managing that client type. In particular Web-tier and HTTP-related functions and data do not belong in an enterprise bean. Keep as much business logic as possible in the EJB tier. By doing so you take advantage of

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.