Remote communication between a client and a server can be achieved using two methods. The first one is the ``Remote Method Invocation'' as described in [Fla97] and the second one, more primitive, is the ``socket communication''. The first one, more abstract, brings the possibility of invoking a method physically located in another machine. In order to use this remote method invocation, client and server must be written in Java. Socket communication is more primitive but makes it possible for clients and servers, written in different languages, to communicate. The remote method invocation is described in 3.8.1 whereas socket communication annotation is described in 3.8.2.
The RMI, or Remote Method Invocation, is a set of Java classes that provides n-tier distributed object computing. A Java client can communicate with a server-side Java object, passing information to and from it. The RMI also provides a persistent connection to the server and manages the exchange of data with no special programming logic needed.
The RMI is designed conceptually in a similar manner to the Object Management Group's CORBA/IDL model. It allows an application to invoke various methods contained within another object running on a different virtual machine. Unlike CORBA/IDL, however, the RMI operates in a homogeneous environment, requiring that all distributed objects be written purely in Java.
At a high level, the RMI is structured simply as a client/server relation. That is, the Java client (known as the client object) interacts with the remote object (the server object). It does so by accessing a reference to the remote object through a device called the RMI registry.
The RMI registry is an application that runs as a background process on a remote server. It contains a table of named services and remote objects, serving as the communications gateway between the client and the remote object.
The remote object also executes as a background process on the remote server and registers, or binds, itself to the RMI registry using a service name. The registry stores the remote object's service name and a reference to the remote object.
Finally, a Java applet (or application) loads the remote object's bindery from the RMI registry. It uses this to understand the structure of the remote object's method parameters. From this point on, the client simply calls, or invokes, the remote object's methods as if they were local to it. All arguments are passed between the client and remote object's methods using a technique called object serialization. (This section will not explain object serialization. For more details, refer to the information available through the Javasoft Web site or see [Fla97].) The YAON graphic syntax does not have different arcs for different kinds of client/server communication. We will use the same standard arc for method application as described in figure 17 but with a new optional annotation.
If the communication is made by a remote method invocation we will add a simple annotation rmi in the client/server arc. With this annotation it is meant that the server is written in Java and the rmi registry runs in background and all the requirements of above are fulfilled.
For networking applications Java provides the Socket and ServerSocket classes as an abstraction of standard socket programming.
If the method application is implemented via sockets the annotation will be socket:nnn where nnn is the port number. This is depicted in figure 27.
|
|