ฉันต้องใช้เซิร์ฟเวอร์ RMI ซึ่งจะเป็นส่วนหน้าสำหรับบริการ RMI อื่นอีกสองบริการ ดังนั้นฉันจึงตัดสินใจว่าสิ่งที่ต้องทำคือมีอินเทอร์เฟซสำหรับสิ่งนี้ ใช้งานอินเทอร์เฟซสำหรับอีกสองบริการ
public interface FrontEndServer extends Remote, BookServer, StudentServer
{
// Block empty so far
}
อย่างไรก็ตามมีวิธีบน StudentServer
/**
* Allows a student to borrow a book
*
* @param studentID of the student who wishes to borrow a book
* @param bookID of the book the student wishes to borrow
* @throws RemoteException
* @throws StudentNotFoundException when a student is not found in the system
*/
void addBookToStudent(int studentID, int bookID) throws RemoteException, StudentNotFoundException;
ฉันต้องการให้ FrontEndServer
โยน BookNotFoundException
ด้วย เนื่องจากบริการนี้จะตรวจสอบว่ามีหนังสืออยู่จริงหรือไม่ ก่อนที่จะพยายามเพิ่มรายละเอียด
สิ่งนี้เป็นไปได้หรือแนวคิดการออกแบบของฉันผิดไปโดยสิ้นเชิง และจริงๆ แล้วนี่เป็นแนวคิดการออกแบบที่ไม่ดีเหมือนกับว่าอินเทอร์เฟซอื่นๆ เปลี่ยนไปทั้งหมด และฉันจะเขียนลายเซ็นวิธีการสำหรับวิธีการทั้งหมดภายใน FrontEndServer
ดีกว่าไหม