Lab2

advertisement

Middleware Lab 2 Introduction to Jini

Student Name: Joey Tawadrous

Laboratory Goals / Objectives

Upon completion of the lab, the individual should understand the basic principles of Jini programming and should be able to create a simple application in JINI.

Overview

Jini (pronounced like genie and also called Apache River) is a network architecture for the construction of distributed systems in the form of modular co-operating services.

Originally developed by Sun, responsibility for Jini is being transferred to Apache under the project name River. Jini provides facilities for dealing with some of the fallacies of

Distributed Computing, problems of system evolution, resiliency, security and the dynamic assembly of service components.

Code mobility is a core concept of the platform and provides many benefits including non-

Protocol dependence. One of the goals of Jini is to shift the emphasis of computing away from the traditional disk-drive oriented approach, to a more network oriented approach.

Thus resources can be used across a network as if they were available locally.

Jini is based on Java, and is similar to RMI but more advanced. Jini allows more advanced searching for services, through a process of discovery of published services (making Jini more similar to the SOA concept). There are three main parts to a Jini scenario.

These are the client, the server, and the lookup service. The service is the resource which is to be made available in the distributed environment. This can include physical devices (such as printers or disk drives) and software services (for example a database query or message service). The client is the entity which uses the service.

To Do: Download the archive from http://www.cs.ucc.ie/~grigoras/CS3311/Practicals .

Unpack it in a directory of your choice and then follow the instructions in the readme.doc file.

Questions

1.

What is the output of your first Jini application?

 “server: The method sayHello() in MyService was called”

2.

What is the role of the MyServiceInterface.java?

 The role of MyServiceInterface.java file is to construct the ‘sayHello’ method.

This method can then be used by any class that implements the

MyServiceInterface class. In fact, if a class implements the MyServiceInterface then that class has no choice but to implement the ‘sayHello’ method. Thus, interfaces are used to define methods that will be used in other classes that implement the interface. These interfaces make sure that the methods are used in the correct way. The MyServiceInterface is implemented by the MyService class and it is also used In the MyClient class.

3.

What are the roles of MyService.java and MyClient.java?

 The MyService. Java class file creates objects for the server interface, the lookup which looks for clients that are connecting, the registrar and the service item.

The MyService class then creates the attributes that describe the server and register. This is then used with the lookup service to find registers.

 The MyClient.java class file gets the lookup service’s ServiceRegistrar and then looks for the HelloWorldServer. If the HelloWorldServer is found the HelloWorld method is called, else an exception is thrown.

4.

Using what you learnt by running and analysing your first Jini application, summarize what is the structure of a Jini application and how does it work? What are the main components and how do they interact?

 The Jini architecture consists of two services, server and client. A service will be a server if it is offering a service. A service will be a client if it is looking for a service. Each service has certain methods that need to be used in order for that particular service to be communicated with. In order to know what services are offered by a particular service, the particular service is represented by a java object. On the other hand the lookup service is what searches for clients who wish connect to servers which offer services. When a client wants to avail of a service, it sends a request to the lookup service which then connects it to the server that is offering the service.

Download