A.2 Stubs and Skeletons

 <  Day Day Up  >  

In RMI, an object residing on a server machine may be manipulated by another object residing on a remote client machine. The terms client and server here apply only for this single call, because in a later transaction, the machine that acted as the server can also act as a client and request an RMI from another machine, which would be the server for this new interaction. When it wants to invoke a remote method, a client object calls a Java method that is encapsulated in a surrogate object called the stub . The stub resides on the same machine as the client. The stub then uses the Java object serialization mechanism to send data in a format suitable for transporting the parameters and the method call to a process on the server. The stub builds an information block that consists of

  • An identifier of the remote object to be used

  • An operation number, describing the method to be called

  • The marshalled [1] parameters

    [1] Marshalling is the mechanism of encoding the parameters into a format appropriate to transport objects across the network.

This information block is sent to the server. A skeleton object residing at the server end receives this information block and takes the appropriate actions:

  • Unmarshals the parameters sent by the stub

  • Calls the appropriate method on the object residing on the server

  • Captures any Exception s generated owing to the call on the server or any return value to be sent back to the stub on the client

  • Sends a block in a marshalled form back to the client

Now, the stub receives the response from the skeleton and unmarshals the return value or the Exception s. The stub is also responsible for passing the return value or the Exception to the process that called the stub initially.

Starting with Java 2 SDK, Standard Edition, V1.2, an additional stub protocol has been introduced that eliminates the need for skeletons in environments that involve the Java 2 SDK platform only. Instead, generic code is used to carry out the duties performed by skeletons in the JDK V1.1.

 <  Day Day Up  >  


Enterprise Java Security. Building Secure J2EE Applications
Enterprise Javaв„ў Security: Building Secure J2EEв„ў Applications
ISBN: 0321118898
EAN: 2147483647
Year: 2004
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net