![]() ![]() ![]() ![]() |
Storing Objects in the Directory |
The Java Remote Method Invocation (RMI) system is a mechanism that enables an object on one Java virtual machine to invoke methods on an object in another Java virtual machine. Any object whose methods can be invoked in this way must implement the java.rmi.Remote interface. When such an object is invoked, its arguments are marshalled and sent from the local virtual machine to the remote one, where the arguments are unmarshalled and used. When the method terminates, the results are marshalled from the remote machine and sent to the caller's virtual machine.To make a remote object accessible to other virtual machines, a program typically registers it with the RMI registry. The program supplies to the RMI registry the string name of the remote object and the remote object itself. When a program wants to access a remote object, it supplies the object's string name to the RMI registry on the same machine as the remote object. The RMI registry returns to the caller a reference (called "stub") to the remote object. When the program receives the stub for the remote object, it can invoke methods on the remote object (through the stub). A program can also obtain references to remote objects as a result of remote calls to other remote objects or from other naming services. For example, the program can look up a reference to a remote object from an LDAP server that supports the schema defined the Internet-draft draft-ryan-java-schema-02.txt.
The string name accepted by the RMI registry has the syntax "rmi://hostname:port/remoteObjectName", where hostname and port identify the machine and port on which the RMI registry is running, respectively, and remoteObjectName is the string name of the remote object. hostname, port, and the prefix, "rmi:", are optional. If hostname is not specified, it defaults to the local host. If portis not specified, it defaults to 1099. If remoteObjectName is not specified, then the object being named is the RMI registry itself. See the RMI specification for details.
RMI can be supported using different protocols: the Java Remote Method Protocol (JRMP) and the Internet Inter-ORB Protocol (IIOP). The JRMP is a specialized protocol designed for RMI; the IIOP is the standard protocol for communication between CORBA objects. RMI over IIOP allows Java remote objects to communicate with CORBA objects which might be written in a non-Java programming language.
Some service providers, such as Sun's LDAP service provider, support the binding of java.rmi.Remote objects into directories. By binding java.rmi.Remote objects or RMI registries into an enterprise-wide, shared namespace such as the LDAP, RMI clients can look up java.rmi.Remote objects without knowing on which machine the objects are running.
Binding a Remote Object
Under construction. This section is being updated to describe how to bind java.rmi.Remote objects using the schema described in the Internet-draft draft-ryan-java-schema-02.txt.
Storing Objects in the Directory: End of Lesson
![]()
![]()
What's next? Now you can:
- Continue on in this trail to learn how to read Java objects from the directory.
- Go to the Representation in the Directory
lesson to read about the physical representation of Java objects in the directory.
![]() ![]() ![]() ![]() |
Storing Objects in the Directory |