DISTRIBUTED OBJECTS AND MIDDLEWARE TECHNOLOGIES Flashcards
Briefly describe middleware
• Middleware in this context is a software that provides services
beyond those provided by the operating system to enable the
various components of a distributed system to communicate and
manage data.
• Middleware supports and simplifies complex distributed
applications.
Give examples of middleware technologies
- RPC
- CORBA
- COM
- DCOM
- Java RMI
Briefly describe RMI
• RMI stands for Remote Method Invocation. It is a mechanism
that allows an object residing in one system (JVM) to
access/invoke an object running on another JVM.
• RMI is used to build distributed applications; it provides
remote communication between Java programs.
• It is provided in the package java.rmi.
Illustrate java RMI using a diagram
*see notes for pic
Describe the different parts of the RMI
• Transport Layer − This layer connects the client and the
server. It manages the existing connection and also sets up
new connections.
• Stub − A stub is a representation (proxy) of the remote
object at client. It resides in the client system; it acts as a
gateway for the client program.
• Skeleton − This is the object which resides on the server
side. stub communicates with this skeleton to pass request
to the remote object.
• RRL(Remote Reference Layer) − It is the layer which
manages the references made by the client to the remote
object.
Briefly describe how RMI works
• When the client makes a call to the remote object, it is
received by the stub which eventually passes this request to
the RRL.
• When the client-side RRL receives the request, it invokes a
method called invoke() of the object remoteRef. It passes
the request to the RRL on the server side.
• The RRL on the server side passes the request to the
Skeleton (proxy on the server) which finally invokes the
required object on the server.
• The result is passed all the way back to the client.
Describe a message in the RMI process
• Whenever a client invokes a method that accepts
parameters on a remote object, the parameters are bundled
into a message before being sent over the network.
• These parameters may be of primitive type or objects.
• In case of primitive type, the parameters are put together
and a header is attached to it.
What is marshalling and unmarshalling
• In case the parameters are objects, then they are serialized.
• This process is known as marshalling.
• At the server side, the packed parameters are unbundled
and then the required method is invoked.
• This process is known as unmarshalling.
What is a remote object
A remote object is an object whose method can be invoked
from another JVM.
What are the tasks of the stub
• It initiates a connection with remote Virtual Machine
(JVM),
• It writes and transmits (marshals) the parameters to the
remote Virtual Machine (JVM),
• It waits for the result
• It reads (unmarshals) the return value or exception, and
• It finally, returns the value to the caller.
What are the tasks of the skeleton
- It reads the parameter for the remote method
- It invokes the method on the actual remote object, and
- It writes and transmits (marshals) the result to the caller.
What is the RMI registry
RMI registry is a namespace on which all
server objects are placed.
Each time the server creates an object, it
registers this object (using a unique name
known as bind name.) with the RMIregistry
(using bind() or reBind() methods).
*See notes for pic
What happens when a client seeks to invoke a remote object
• To invoke a remote object, the client needs a
reference of that object.
• At that time, the client fetches the object
from the registry using its bind name (using
lookup() method).
*See notes for pic
What are the requirements for a distributed application
• The application need to locate the remote method
• It need to provide the communication with the
remote objects.
• The application need to load the class definitions for
the objects.
*The RMI application have all these features, so it is called
the distributed application.
What are the steps to writing a java distributed application
- Create the remote interface
- Provide the implementation of the remote interface
- Develop server program
- Develop client program
- Compile application
- Execute the application
1.Create the remote interface
What is the function of a remote interface
• A remote interface provides the description of all the methods of a
particular remote object.
• The client communicates with this remote interface.
1.Create the remote interface
Outline the process of creating a remote interface with the relevant code
• Create an interface that extends the predefined interface Remote which belongs to the package. • Declare all the business methods that can be invoked by the client in this interface. • Since there is a chance of network issues during remote calls, an exception named RemoteException may occur; throw it. • Following is an example of a remote interface. Here we have defined an interface with the name Hello and it has a method called printMsg().
*See notes for code
2.Implementing Remote Interface
What are the different ways to implement the remote interface
• We can write an implementation class separately or we can directly make the server program implement this interface. • To develop an implementation class − • Implement the interface created in the previous step. • Provide implementation to all the abstract methods of the remote interface.
*See notes for code
3.Developing a server program
How is the server program linked to the remote interface
An RMI server program should implement the remote interface or extend the
implementation class.
3.Developing a server program
Outline the process of developing a server program
• Create a client class from where you want invoke the remote object.
• Create a remote object by instantiating the implementation class as shown
below.
• Export the remote object using the method exportObject() of the class
named UnicastRemoteObject which belongs to the package
java.rmi.server.
• Get the RMI registry using the getRegistry() method of the LocateRegistry
class which belongs to the package java.rmi.registry.
• Bind the remote object created to the registry using the bind() method of
the class named Registry. To this method, pass a string representing the
bind name and the object exported, as parameters.
*See notes for code
4.Developing client program
Outline the process of creating a client pri=ogram
• Get the RMI registry using the getRegistry() method of the LocateRegistry class which belongs to the package java.rmi.registry. • Fetch the object from the registry using the method lookup() of the class Registry which belongs to the package java.rmi.registry. • To this method, you need to pass a string value representing the bind name as a parameter. This will return you the remote object. • The lookup() returns an object of type remote, down cast it to the type Hello. • Finally invoke the required method using the obtained remote object.
*See notes for code
5.Compiling the application
- Compile all the application modules separately
- i.e.
- Compile the Remote interface.
- Compile the implementation class.
- Compile the server program.
- Compile the client program.
• You can compile the application using Javac *.java
command. This will compile all the modules at once
6.Executing the application
• Step 1 − Start the rmi registry using the start rmiregistry
command
• Step 2 − Run the server class file by typing command java
Server
• Step 3 − Run the client class file by typing command java
Client
A multicorporate has been running a legacy Information System implemented in C programming language. As a senior developer lead, you go ahead and create some important separate system that requires integration to the legacy system for effective working. To avoid a long process that would involve rewriting the code of the legacy system due to its large source code, you decide to do research on a technology that would bridge the gap between your application and the legacy system.
a) Describe your findings of the technology to be implemented that would facilitate the integration of your application and the legacy system without changing of either of the source code. (3 marks)
b) Using a diagram, explain the working of the technology described above. (5 marks)
a) CORBA-The Common Object Request Broker Architecture (CORBA) is a standard defined by the Object Management Group (OMG) that enables software components written in multiple computer languages and running on multiple computers to work together.
CORBA is a standard for distributing objects across networks so that operations on those objects can be called remotely.
b)In a CORBA environment, programs request services through an object request broker (ORB), which allows components of distributed applications to find each other and communicate without knowing where applications are located on the network or what kind of interface they use. ORBs are the middleware that enable client and server programs to establish sessions with each other, independent of their location on the network or their programming interface.
The client issues a call to an API, which is intercepted by the ORB. The ORB takes the call and is responsible for locating a server object that is able to implement the request. Once it has located such an object, the ORB invokes the object’s method and passes it any parameters submitted by the client.
The results are then returned to the client. ORBs communicate among themselves using the General Inter-ORB Protocol (GIOP) or the Internet Inter-ORB Protocol (IIOP) so that any ORB can fulfill any client request on the network
*See https://networkencyclopedia.com/common-object-request-broker-architecture-corba/ for pic