TAILIEUCHUNG - programming LEGO MINDSTORMS phần 9

Tuy nhiên, đối tượng còn sơ khai không thực hiện các mã trong những cuộc gọi phương thức, nó biết làm thế nào để truyền đạt lại cho các đối tượng dịch vụ ban đầu, mà cũng có thể được chạy trên máy khác, và đối tượng ban đầu không xử lý. Dòng chảy này được thể hiện trong hình 9,8. Hình 9,8: | 354 Chapter 9 Programming LEGO MINDSTORMS with Jini 5. However the stub object does not implement the code within those method calls it knows how to communicate back to the original service object which may well be running on another machine and that original object does all of the processing. This flow is shown in Figure . Figure The Use of RMI Stubs in a Jini Architecture Now that would make sense if the service object was expecting to communicate with an RCX via a serial port then it still could because the object would be invoked in the original JVM that created it. And if that object held references to other objects these references would still be valid for the same reasons. The only problem is that we have to write an absolutely enormous amount of code to achieve this complex interaction between objects across the network right Wrong Fortunately Jini s use of RMI means that this can be achieved with essentially no coding whatsoever There are several ways to implement this but the one we will use in the examples is by extending a class known as . Basically the steps required are as follows 1. Make sure that the class of the object that is to be registered as a service extends UnicastRemoteObject and also ensure that it still implements Serializable . 2. When you compile your service s class for example run the RMI compiler against it to produce a stub class. Programming LEGO MINDSTORMS with Jini Chapter 9 355 3. Make sure that the stub class file is accessible to the client via the HTTP server. That s it That s all you have to do the RMI compiler will generate all of the code required for the stub so that the stub and the original object know how to communicate across JVMs and even across a still specify the original class name in your code Jini knows to instantiate the stub and register that with reggie instead of your local object. Generating the stub class using the .

Đã 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.