| Start |
|---|
Callback: invoking methods on a "client" OverviewIn this example 2 clients send information to each other through a server. One client sends the server a number which is relayed to the second client. The second client halves the number and sends it back to the first client through the server. The first client does the same. The server stops the communication when the number returned to it by any of the clients is less than 10. The return value from the server to the clients (the number it got converted to string representation) then backtracks the process.
The shared remote interfacesThe login server: The server: The client: The implementationsThe login server: The server: The client: Running the example:
The outputs will appear in 3 consoles since there are 3 JVMs. here they are lumped together: Client2 logged in |
| Client-Server: invoking methods in one JVM from another The shared remote interface: The server implementing the shared remote interface: The client invoking a method on the server (remotely): Output: Server received: "120" |
| Simple RMI example with Client and Server implementation This is a simple RMI example with five Java classes and two packages, server and client. Server PackagePersonListInterface.java PersonListImplementation.java Server.java Client packagePersonListLocal.java PersonTest.java Test your application
RemarksRMI requires 3 components: client, server and a shared remote interface. The shared remote interface defines the client-server contract by specifying the methods a server must implement. The interface must be visible to the server so that it can implement the methods; the interface must be visible to the client so that it knows which methods ("services") the server provides. The shared remote interface is any interface extending
In the project setup, the client and server projects are completely unrelated, but each specifies a shared project in its build path. The shared project contains the remote interfaces. |
Read Article
https://develop.horje.com/learn/1434/reference