• No results found

Distributed Objects

N/A
N/A
Protected

Academic year: 2022

Share "Distributed Objects"

Copied!
41
0
0

Loading.... (view fulltext now)

Full text

(1)

Distributed Objects

(2)

Introduction

A distributed object-based system is a collection of objects that isolates the

requesters of services (clients) from the providers of services (servers) by a

well-defined encapsulating interface.

In other words, clients are isolated from

the implementation of services as data

representations and executable code.

(3)

This is one of the main differences that distinguishes the distributed object-based model from the pure

client/server model.

In the distributed object-based model, a client sends a message to an object, which in turns interprets the message to decide what service to perform.

This service, or method, selection could be performed by either the object or a broker. The Java Remote

Method Invocation (RMI) and the Common Object

Request Broker Architecture (CORBA) are examples

of this model.

(4)

The Roles of Client & Server

Client Server

Send request data

Return response data

Transmitting objects between client and server

(5)

The client/server model is a form of

distributed computing in which one program (the client) communicates with another

program (the server) for the purpose of exchanging information.

In this model, both the client and server

usually speak the same language -- a protocol

that both the client and server understand --

so they are able to communicate.

(6)

While the client/server model can be

implemented in various ways, it is typically done using low-level sockets.

Using sockets to develop client/server systems means that we must design a

protocol, which is a set of commands agreed

upon by the client and server through which

they will be able to communicate.

(7)

As an example, consider the HTTP

protocol that provides a method called GET, which must be implemented by all web servers and used by web clients

(browsers) in order to retrieve

documents.

(8)

The Distributed Objects Paradigm

(9)

Remote Method Call with Proxies

(10)

A distributed object is provided, or exported, by a

process, here called the object server. A facility, here called an object registry, must be present in the

system architecture for the distributed object to be registered.

To access a distributed object, a process –an object client–looks up the object registry for a reference to the object. This reference is used by the object client to make calls to the methods.

A reference is a “handle”for an object; it is a

representation through which an object can be

located in the computer where the object resides.

(11)

Logically, the object client makes a call directly to a remote method.

In reality, the call is handled by a software

component, called a client proxy, which interacts with the software on the client host that provides the

runtime support for the distributed object system.

The runtime support is responsible for the

inter-process-communication needed to transmit the

call to the remote host, including the marshalling of

the argument data that needs to be transmitted to

the remote object.

(12)

A similar architecture is required on the server side, where the runtime support for the distributed object system handles the receiving of messages and the unmarshalling of data, and forwards the call to a software component called the server proxy.

The server proxy interfaces with the distributed object to invoke the method call locally, passing in the unmarshalled data for the arguments.

The method call results in the performance of some tasks on the server host. The outcome of the execution of the method,

including the marshalled data for the return value, is forwarded

by the server proxy to the client proxy, via the runtime support

and network support on both sides.

(13)

The distributed object paradigm has been widely adopted in distributed applications, for which a large number of mechanisms based on the paradigm are available. Among the most well known of such mechanisms are:

Java Remote Method Invocation(RMI),

the Common Object Request Broker Architecture(CORBA) systems,

the Distributed Component Object Model(DCOM),

mechanisms that support the Simple Object Access Protocol(SOAP).

Of these, the most straightforward is the Java RMI

(14)

RMI

RMI is a distributed object system that enables you to easily develop distributed Java applications.

Developing distributed applications in RMI is simpler than developing with sockets since there is no need to design a protocol, which is an error-prone task.

In RMI, the developer has the illusion of calling a local method from a local class file, when in fact the arguments are shipped to the remote target and

interpreted, and the results are sent back to the

callers.

(15)

Remote Method Invocation (RMI) is an object-oriented

implementation of the Remote Procedure Call model. It is an API for Java programs only.

Using RMI, an object server exports a remote object and

registers it with a directory service. The object provides remote methods, which can be invoked in client programs.

Syntactically:

A remote object is declared with a remote interface, an extension of the Java interface.

The remote interface is implemented by the object server.

An object client accesses the object by invoking the remote methods associated with the objects using syntax provided for remote method invocations.

(16)

Stubs and Parameter Marshalling

When client wants to invoke a remote method on a remote object, it actually calls an

ordinary method on proxy object called a stub.

Stub resides on the client machine.

Stub packages the parameters used in the remote method into a block of bytes.

This packaging uses the device independent

encoding for each parameter.

(17)

The process of encoding the parameters is called parameter marshalling.

The purpose of parameter marshalling is to convert the parameters into a

format suitable for transport from one

virtual machine to another.

(18)

The stub method on the client machine builds an information block that consists of:

An identifier of the remote object to be used

A descriptor of the method to be called

The marshalled parameter

(19)

The stub then send this information to

the server.

(20)

Server side, a receiver object performs the following actions for every remote method call:

It unmarshals the parameters

It locates the object to be called

It calls the desired method

It capture and marshals the return value or exception of the call

It sends a package consisting of the marshalled

return back to the stub on the client.

(21)

The client stub un-marshals the return value or exception from the server.

This value becomes the return of the stub call.

Or, if the remote method threw an

exception, the stub rethrows it in the

process space of the caller.

(22)

Client Stub Skeleton Server

Call stub method locally

Send marshalled parameters Call Server method locally

Return method result Send marshalled return value

or exception Return value or

throw exception

Parameter marshalling

(23)

The syntax for remote method call is the same as of local call.

Interfaces are abstract entities that only spell out what method can be called along with their

signatures.

Variables whose type is an interface must always be bound to an actual object of some type.

When remote methods are called, the object variable refers to a stub object.

The client program does not actually know the type of those objects.

The stub classes and the associated objects are

created automatically.

(24)

Dynamic Class Loading

When you pass a remote object to

another program, either as a parameter or return value of a remote method,

then program must have the class file for that object.

As you know basic work of class loader

is to load the necessary class files from

the server

(25)

Whenever a program loads new code from another network location, there is a security issue.

For this reason we need to use a security manager in RMI client applications.

This is a safety mechanism that protects the

program from viruses in stub code.

(26)

Setup for RMI

You must run programs on both the server and client computers.

The necessary object information may

be separated into client side interfaces

and server side implementations.

(27)

Interfaces & Implementations

Client program needs to manipulate server objects, but it doesn’t actually have copies of them.

The objects themselves reside on the server.

The client code must still know what it

can do with those objects.

(28)

Their capabilities are expressed in an interface that is shared between the

client and server and so resides on both

machines.

(29)

RMI Architecture

(30)

CORBA

The Common Object Request Broker Architecture (or CORBA) is an industry

standard developed by the Object Management Group (OMG) to aid in distributed objects

programming.

It is important to note that CORBA is simply a specification. A CORBA implementation is

known as an ORB (or Object Request Broker).

There are several CORBA implementations available on the market such as VisiBroker, ORBIX, and others. JavaIDL is another

implementation that comes as a core package

with the JDK1.3 or above.

(31)

CORBA was designed to be platform and language independent.

Therefore, CORBA objects can run on any

platform, located anywhere on the network, and can be written in any language that has

Interface Definition Language (IDL) mappings.

Similar to RMI, CORBA objects are specified with interfaces.

Interfaces in CORBA, however, are specified in IDL.

While IDL is similar to C++, it is important to

note that IDL is not a programming language.

(32)

The Genesis of a CORBA Application

There are a number of steps involved in developing CORBA applications. These are:

Define an interface in IDL

Map the IDL interface to Java (done automatically)

Implement the interface

Develop the server

Develop a client

Run the naming service, the server, and the

client.

(33)

Code-wise, it is clear that RMI is simpler to work with since the Java

developer does not need to be familiar with the Interface Definition Language (IDL). In general, however, CORBA

differs from RMI in the following areas:

CORBA interfaces are defined in IDL and RMI interfaces are defined in Java. RMI allows you to write all interfaces in

Java.

(34)

CORBA supports in and out

parameters, while RMI does not since local objects are passed by copy and remote objects are

passed by reference.

(35)

CORBA was designed with language

independence in mind. This means that some of the objects can be written in

Java, for example, and other objects can be written in C++ and yet they all can

interoperate. Therefore, CORBA is an ideal mechanism for bridging islands between different programming

languages. On the other hand, RMI was

designed for a single language where all

objects are written in Java.

(36)

CORBA objects are not garbage collected. As we mentioned, CORBA is language

independent and some languages (C++ for

example) does not support garbage collection.

This can be considered a disadvantage since once a CORBA object is created, it continues to exist until you get rid of it, and deciding when to get rid of an object is not a trivial task. On the other hand, RMI objects are garbage

collected automatically.

(37)

CORBA depends on having an Object Request Broker available on both client and server.

ORB is a kind of universal translator for

inter object CORBA communication.

(38)

IDL: Interface Definition Language

In this interface definition ends with semicolon.

string class is started with small s. this string class refer to the CORBA notion of string.

In java String contains 16 bit unicode

characters but in CORBA string contains

only 8 bit characters.

(39)

IDL to java compiler translates IDL definitions to definitions for java

interfaces.

(40)

IDL interface

interface IDLTest {

string string_test();

};

After executing idlj IDLTest.idl

It will produce IDLTestOperations.java interface IDLTest

{

String string_test();

}

(41)

SOAP

Short for Simple Object Access Protocol, a lightweight

XML-based messaging protocol used to encode the information in Web service request and response messages before sending them over a network. SOAP messages are independent of any operating system or protocol and may be transported using a variety of Internet protocols, including SMTP, MIME, and HTTP.

WSDL

Short for Web Services Description Language, an XML-formatted language used to describe a Web service's capabilities as

collections of communication endpoints capable of exchanging

messages. WSDL is an integral part of UDDI, an XML-based

worldwide business registry. WSDL is the language that UDDI

uses. WSDL was developed jointly by Microsoft and IBM.

References

Related documents

Descriptive statistics was used to analyze socio-economic characteristics of household heads and share of each energy source on total expenditure on energy while

Variable Coefficient Std. Error t-Statistic Prob. All CoCo features included as explanatory variables are also regressed separately on the dependent variable in

We Treat The Open Group Member’s to be an invited ReGIS Member’s without fee.; We had published in 2014, 24 GIS FORUM Members News Letters “#415 to #438 (Mail

Using available published data from relevant surveys of AMF in flowering plants, we calculated the proportion of non- Glomeraceae DNA sequences and, where possible, the proportion

Longitudinal collection of electronic health information for and about persons, where health information is defined as information pertaining to the health of an

The client needs both the interface code for the remote object and the generated stub class. With those two elements, it can use remote objects as if they were local to its own

I The RMIClassLoader is used to load those classes not directly used by the client or server application: the stubs and skeletons of remote objects, and extended classes of

Second, to the extent that a direct analogy to “time, place, and manner” regulations is appropriate, most—I would say almost all— regulations of weapons are indeed such