TAILIEUCHUNG - Writing Enterprise Applications with Java™ 2 SDK, Enterprise Edition phần 5

CalcHome Giao diện CalcHome là không thay đổi. Nó có cùng một phương pháp tạo ra mà trả về một thể hiện của giao diện từ xa. Đậu gói; nhập khẩu, nhập khẩu, nhập khẩu CalcHome giao diện công cộng kéo dài EJBHome {công cộng Calc create () ném CreateException, RemoteException;} | 46 SEPTEMBER 27 2000 Change the Session Bean In this lesson and as shown in Figure 14 the entity bean is a client of the session bean. This means the entity bean gets its data from the session bean instead of from BonusServiet as it did in Lesson 2 A Simple Entity Bean page 27 . So the caicBonus method in the session bean is modified to take the social security number as a parameter and create the entity bean. Figure 14 Beans Working Together CalcHome The caicHome interface is unchanged. It has the same create method that returns an instance of the remote interface. package Beans import import import public interface CaicHome extends EJBHome public Calc create throws CreateException RemoteException LESSON 3 COOPERATING ENTERPRISE BEANS SEPTEMBER 27 2000 47 Calc The calcBonus method in the Calc interface is changed to take the social security number as a parameter. This is so CaicBean can pass the bonus and social security number to the entity bean after calculating the bonus value. A new getRecord method is added so caicBean can find an entity bean by its primary key the social security number . Also the caicBonus method signature throws DupiicateKeyException and CreateExcep-tion. This is so BonusServiet can catch and handle either of these exception conditions. DuplicateKeyException descends from CreateException. If you design the caicBonus method to throw DupiicateKeyException but catch CreateException DupiicateKeyEx-ception is not thrown. The way around this is to have caicBonus throw both Dupii-cateKeyException and CreateException. package Beans import import import import pubiic interface Caic extends EJBObject pubiic Bonus caicBonus int muitipiier doubie bonus String socsec throws RemoteException DupiicateKeyException CreateException pubiic Bonus getRecord String socsec throws .

TỪ KHÓA LIÊN QUAN
Đã 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.