Java Remote Object Model
- Describes the given “Remote Object” model.
- Shows some limitations and issues with this model.
- RMI Source code
These notes assume the Reader is familiar with the “Remote Procedure Call – RPC” model.
- The discussion centers around how to provide a “Distributed Object Model”.
- Remote Method Invocations
- Method invocations on objects across different JVMs
- Object Class Methods
- The methods of the Object class – equals, hashCode, toString, clone, finalize
- Remote access and faults
- Throwing RemoteException
- Dynamic stubs and proxies
Remote Method Invocation Model
Interfaces and Objects
- Java has interfaces and objects
- For Remote invocations, Java defines RemoteInterface and RemoteObject classes.
- All clients are expected to use the Remote, or an interface extended from it.
- This is a marker interface to convey that remote calls need to be invoked on the same
- The servers implement “Remote Objects” by extending RemoteObject class.
Stubs and Serialization
- For every call that is made, stubs on the client side
- convert the object-calls to network protocol and vice-versa
- To allow for generic stubs to be written,
- Java defines a standard Object Serialization format, to convert to the wire and vice-versa
For consistency between the server version and the server stubs,
- The Java class-loader can load the stubs from an external URL. This could be the RMI server
Every Remote Method must be declared to throw a RemoteException
- This is to handle when there is a communication failure across systems.
All Object methods need to be revisited for re-implementation under the new “Distributed Object Model”.
|getClass||Returns the stub-class. Requires no changes|
|hashCode||Re-implemented to hash the ReferenceId – not “Content based”This is done to avoid a RPC for performance and integration reasons|
|equals||Re-implemented to hash the ReferenceId – not “Content based”This is done to avoid a RPC for performance and integration reasons|
|clone||Implemented to clone the reference|
|wait||Lock on the local objectObject on server can be accessed by different clients|
|notify||Unlock on local object|
|notifyAll||Unlock on local object|
|toString||Objectifies the string reference|