What is Registry Service for RMI?
- The registration of the remote object must be done by the server in order for the client to look it up, is called the RMI Registry.
- In RMI, the client must contact an RMI registry, so that the server side application will be able to contact the client’s registry which points the client in the direction of the service. The client registers the service with the registry so that it is transparent to even for the server.
Explain how URL convention is used for accessing the registry.
- The class rebind () method of java.rmi.Naming class is used to specify the port number.
- For example if the registry is running on a port number 3271 of an application named HelloRMIRegistry the following is the usage of the URL to reference the remote object:
Naming.rebind ("//myhost:3271/ HelloRMIRegistry ", obj);
- The URL stored on the web page needs to specify the non-default port number.
- When the server’s remote objects created by the server can include the URL from which the stub class can dynamically be downloaded to the client.
- The following example depicts this:
- Where ExampleRMIURL is the name of the application.
Explain how to bind an object to the registry.
- If an object implements the java.rmi.Remote interface, an object is to be bound to registry context. Each registry context implements the Referenceable interface.
- The object factory is implemented by the RegistryContextFactory which converts the registry references into the corresponding registry contexts or remote objects.
- To construct the registry constructs, the URL of the registry must be determined. In this way the remote objects will be bounded with registry contexts.