Uploaded by hack hacker

RMI Presentation

advertisement
RMI Presentation
Dr. Amjad Hawash
Introduction
•
We are producing two main objects:
The server object: which will be
composed of two main java programs:
1.
I.
The program that represents the interface:
this program contains all of the prototypes
of all of the functions that the object server
can execute, and these prototypes
represents the functions (services) offered
by that object (the interface of that server).
Example:
public interface someInterface
extends Remote {
// here we put all of the services
// i.e. all of the prototypes of the functoins
datatype somefunction (parameters)
throws RemoteException;
// other prototypes.
}
• We extends the previous interface from
RemoteException, because failure might
be from:
– Failure related problems.
– Protocol errors.
– Failure during linking and unlinking with server
object.
II.
The program that represents the
implementation of the server services
(functions): this program contains the
implementations (bodies) of all of the
functions (services) mentioned in the
previous file (interface file)
For example:
public class someClass extends
UnicastRemoteObject implements
someInterface {
// we put here all of the bodies of all of the
functions, also we put constructors.
Also including main() function which contains a
code for creating the server object, and of
course when it is created, all of its services
will be ready for invocation. Also inside main()
function we bind this object with a name in
order to be used from clients objects.
2. The client object that composed from
one main java program, this program
contains all of the calling for needed
functions that are provided from the
server(s).
In the main() function of the client, we put the
necessary code to link with the server
object, using the IP address, or DNS name
for the computer that holds that object.
After that we begin calling the functions of the
server object.
Relationship
• How the previous composition of java
programs related to distributed
systems???
• When you have client objects and server
objects on different computers, and when
you begin calling methods (services) from
servers by the clients, the execution of
these methods will be on the PCs that
contain the server objects.
• Now, using the processor, memory, OS,
…etc., of these machines, when calling
the servers’ functions will yield to
composing a distributed system.
Working
• In our example, Hello we did the following:
– Create java programs.
– Compile them ( javac *.java).
– Start rmiRegistry port#, which is some how connecting
clients with servers (start rmiRegistry)
– Start server program (java HelloServer)
The previous steps are done completely on the PC that will
hold the server object.
– Compile Client program
– Run client program.
The previous two steps done on the PC that will
hold the client object.
Some Terms
• A remote object: is the one whose
methods can be invoked from other
objects( clients).
• A remote interface: is the interface that
contains all of the methods (declarations)
that will be provided by the remote objects.
• Stubs and Skeletons: when a client
obtains a reference for a remote object,
the remote object is not sent over the
network to the client. Actually the clients
gets a proxy or a stub. A stub acts as
client’s local representative for the remote
object. The client invokes a method on the
local stub, and the stub is responsible for
calling the method on the remote object.
• The skeleton is the server side proxy for
the remote object. It is much like the stub
class but resides on the server. The
skeleton is responsible for calling the
actual remote object implementation.
Download