26-08-2016, 07:04 PM
27-08-2016, 10:51 AM
During the presentation of the RMI Architecture, one question has been repeatedly postponed: "How does a client find an RMI remote service? " Now you'll find theanswer to that question. Clients find remote services by using a naming or directory service. This may seem like circular logic. How can a client locate aservice by using a service? In fact, that is exactly the case. A naming or directoryservice is run on a well-known host and port number.(
Well-known
meaning everyone in an organization knowing what it is).RMI can use many different directory services, including the Java Naming andDirectory Interface (JNDI). RMI itself includes a simple service called the RMIRegistry,RMI registry. The RMI Registry runs on each machine that hosts remoteservice objects and accepts queries for services, by default on port 1099.On a host machine, a server program creates a remote service by first creating alocal object that implements that service. Next, it exports that object to RMI. Whenthe object is exported, RMI creates a listening service that waits for clients toconnect and request the service. After exporting, the server registers the object inthe RMI Registry under a public name.On the client side, the RMI Registry is accessed through the static class Naming. It provides the methodlookup()that a client uses to query a registry. The methodlookup()accepts a URL that specifies the server host name and the name of thedesired service. The method returns a remote reference to the service object. TheURL takes the form:rmi://<host_name>[:<name_service_port>]/<service_name>where thehost_nameis a name recognized on the local area network (LAN) or aDNS name on the Internet. Thename_service_portonly needs to be specified onlyif the naming service is running on a different port to the default 1099.
Well-known
meaning everyone in an organization knowing what it is).RMI can use many different directory services, including the Java Naming andDirectory Interface (JNDI). RMI itself includes a simple service called the RMIRegistry,RMI registry. The RMI Registry runs on each machine that hosts remoteservice objects and accepts queries for services, by default on port 1099.On a host machine, a server program creates a remote service by first creating alocal object that implements that service. Next, it exports that object to RMI. Whenthe object is exported, RMI creates a listening service that waits for clients toconnect and request the service. After exporting, the server registers the object inthe RMI Registry under a public name.On the client side, the RMI Registry is accessed through the static class Naming. It provides the methodlookup()that a client uses to query a registry. The methodlookup()accepts a URL that specifies the server host name and the name of thedesired service. The method returns a remote reference to the service object. TheURL takes the form:rmi://<host_name>[:<name_service_port>]/<service_name>where thehost_nameis a name recognized on the local area network (LAN) or aDNS name on the Internet. Thename_service_portonly needs to be specified onlyif the naming service is running on a different port to the default 1099.