Jini, third verse Richard Chapman October 13, 1999.

Slides:



Advertisements
Similar presentations
CS Network Programming CS 3331 Fall CS 3331 Outline Socket programming Remote method invocation (RMI)
Advertisements

Introduction to classes Sangeetha Parthasarathy 06/11/2001.
Prof. Dr.-Ing. habil. B. Steinbach - Informatik / Softwaretechnologie und Programmierungstechnik - Institut für Informatik virtuelle Maschine Verteilte.
- 1 - Jini in the Enterprise O'Reilly Conference on Java Scott Oaks Sun Microsystems
11 Copyright © 2005, Oracle. All rights reserved. Using Arrays and Collections.
8 March 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
JSP and Servelets.
Technische universität dortmund Service Computing Service Computing Prof. Dr. Ramin Yahyapour IT & Medien Centrum 12. November 2009.
The Jini Technology Lookup Service. How Does It Work Services and clients find a lookup service using the discovery protocol Services advertise themselves.
1 Jini Tutorial, Part 3 Jini Programming. 2 Tutorial outline Part 1 Introduction Distributed systems Java basics Remote Method Invocation (RMI) Part 2.
Sequence of characters Generalized form Expresses Pattern of strings in a Generalized notation.
Local vs. distributed Objects Differences between local and distributed objects in: –References (to objects) –Activation/Deactivation –Migration –Persistence.
Computer Programming Lab(7).
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Mini project /2 Jini - a new computing paradigm.
Remote method invocation. Introduction First introduced in JDK 1.1. Allows distributed Java programs to work with each others by behaving as if they are.
Java Network Programming Vishnuvardhan.M. Dept. of Computer Science - SSBN Java Overview Object-oriented Developed with the network in mind Built-in exception.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Hand Trace and Output for: int digit = 0; int number = 1423; do { digit = number % 10; System.out.println(digit); number = number / 10; } while (number.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
CS 210 Proxy Pattern Nov 14 th, Revisit the Gumball machine example The same example covered in the State pattern Now we want to add some monitor.
Introduction to Jini & JavaSpaces
CS 603 Jini April 10, What is Jini? Java Middleware Tools to construct federation –Multiple devices, each with Java Virtual Machine –Multiple services.
A Look at Jini Richard Chapman Sept. 30, Jini Motivation Why must everyone be a sysadmin? Why can’t computers scale like the phone system: added.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Parallel Computing using JavaSpaces -Presented by Shilpi Basak Advisor: Prof: Dick Steflik.
Using Lookup Services 1.What are Lookup Services 2.How Clients use lookup services 3.How Services use lookup services 4.Using events.
A Study of Sun Microsystem’s Jini Architecture Casey Detorie CS December 2002.
Jini Connection Technology Kaushik Lahoti. Jini: A Vision n Areas to focus on –Simplicity –Reliability –Scalability.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 23: Review Mon. 12/11.
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
Introduction - What is Jini Technology?
JavaSpaces Prabhaker Mateti Wright State University.
January 26, Jim Waldo Copyright 1999 Sun Microsystems, Inc., all rights reserved.
1 Vrijendra Gokhale, Bernard Menezes K. R. School of Information Technology IIT Bombay User Interfaces for Jini Services The Jini Pattern Language Workshop.
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
Sun’s Jini Lab 2 Service Registration Client Lookup.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
CIS 644 Aug. 25, 1999 tour of Java. First … about the media lectures… we are experimenting with the media format please give feedback.
A Look at Jini Jian He Roy Patrick Tan. Outline History Design Goals An Example Basic Components Top View Infrastructures --- Proxies, Discovery/join.
JavaSpaces TM By Stephan Roorda Source: JavaSpaces specification.
Jini tm NetworkingTechnology Directions Jim Waldo Jini Architect Sun Microsystems, Inc.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
20-Sep-2000Jini™ Connection Technology1 Rochester Institute of Technology Jini™ Connection Technology Alan Kaminsky Information Technology Laboratory Rochester.
Integrated Systems Division Service-Oriented Programming Guy Bieber, Lead Architect Motorola ISD C4I 2000 OOPSLA Jini Pattern Language Workshop Guy Bieber,
1 Lecture 16 Jini Technology Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology
Jini Architecture Alessandro Brawerman. Contents Jini definition Advantages Architecture How it works Websites to check.
CORBA/RMI issues in Nile Authors: F. Handfield (University of Texas, Austin, TX USA) D. Mimnagh (University of Texas, Austin, TX USA) M. Ogg (University.
1 JSK 1.1 A practical Approach Contents –Working with JSK 1.1 –Jini environments –Writing Jini software revisited –Important software packages in the JSK.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Jini Architectural Overview Li Ping
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
Jini Technology 제 1 회 한국 자바 개발자 컨퍼런스 발표자 : 강신동 Mobile : 소속 : ㈜ idosi.com 대표이사 주최 : JavaCommunity.Org.
Netprog Java RMI1 Remote Method Invocation.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 20 A little more on RMI Getting started with.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
JINI – A next Generation Networking Technology Part I – Introduction.
January 26, Ann Wollrath Copyright 1999 Sun Microsystems, Inc., all rights reserved. Java ™ RMI Overview Ann Wollrath Senior Staff Engineer Sun Microsystems,
null, true, and false are also reserved.
The Jini Technology: An overview
Using the Java Library API
An Introduction of Jini Technology
Jini Instructors: Geoffrey Fox and Bryan Carpenter
JINI ICS 243F- Distributed Systems Middleware, Spring 2001
Could Jiro™ Extend the Jini™ Pattern Lanuguage?
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Presentation transcript:

Jini, third verse Richard Chapman October 13, 1999

The interface // HelloWorldServiceInterface.java Package corejini.chapter5; public interface HelloWorldServiceInterface { public String getMessage(); }

Code for the service HelloWorldService.java package corejini.chapter5; import net.jini.discovery.DiscoveryListener; import net.jini.discovery.DiscoveryEvent; import net.jini.discovery.LookupDiscovery; import net.jini.core.lookup.ServiceItem; import net.jini.core.lookup.ServiceRegistrar;

Service code, contd import jini.core.lookup.ServiceRegistration; import java.util.Hashtable; import java.io.IOException; import java.io.Serializable; import java.rmi.RemoteException; import java.rmi.RMISecurityManager;

Service code, proxy object class HelloworldServiceProxy implements Serializable, HelloWorldServiceInterface { public HelloWorldServiceProxy() { } public String getMessage() { return “Hello, world!”; }

Service code, wrapper class public class HelloWorldSerivce implements Runnable { protected final int LEASE_TIME=10*60*1000; protected HashTable registrations = new Hashtable(); protected ServiceItem item; protected LookupDiscovery disco;

Listen for discovery events class Listener implements DiscoveryListener { public void discovered(DiscoveryEvent ev) { System.out.println( “discovered a loookup service!”); ServiceRegistrar[] newregs = ev.getRegistrars(); for (int i=0;i<newregs.length; i++) { if(!registrations.containsKey(newregs[I])) { registerWithLookup(newregs[i]); }

To discard a lookup service public void discarded(DiscoveryEvent ev) { ServiceRegistrar[] deadregs = ev.getRegistrars(); for (int i=0; i<deadregs.length; i++) { registrations.remove(deadregs[i]); } // end of class Listener from previous slide ago }

HelloWorldService constructor public HelloWorldService() throws IOException{ item = new ServiceItem(null,createProxy(),null); //set a security manager if (System.getSecurityManager()==null) { System.setSecurityManager( new RMISecurityManager()); } // search for the “public group”, named by”” disco = new LookupDiscovery(new String[] {“”});

Lookup Lookup service Service item Proxy attribute Service item

HelloWorldService, cont’d //install a listener disco.addDiscoveryListener(new Listener()); } protected HelloWorldServiceInterface createProxy() { return new HelloWorldServiceProxy(); }

HelloWorldService, cont’d protected synchronized void registerWithLookup(ServiceRegistrar registrar) { ServiceRegistration registration = null; try { registration = registrar.register(item, LEASE_TIME); } catch(RemoteException ex) { System.out.println(“Couldn’t register:” + ex.getMessage()); return; }

HelloWorldService, cont’d if (item.serviceID == null) { item.serviceID = registration.getServiceID(); System.out.println(“Set serviceID to “+ item.serviceID); } registrations.put(registrar,registration); // end of registerWithLookup from prev. slide }

Thread to keep the JVM alive // thread in HelloWorldService to make sure // the JVM doesn’t exit public void run() { while (true) { try { Thread.sleep( ); } catch (InterrruptedException ex) { }

Create service, start thread public static void main(String args[]) { try { HelloWorldService hws = new HelloWorldService(); new Thread(hws).start(); } catch (IOException ex) { System.out.println(“Couldn’t”+ “create service:”+ex.getMessage()); } // finally the end of HelloWorldService }

Client code //needs most of the imports that the server did, plus import net.jini.core.lookup.ServiceTemplate; import java.util.Vector;

Client code public class HelloWorldClient implements Runnable { protected ServiceTemplate template; protected LookupDiscovery disco; class Listener implements DiscoveryListener{ public void discovered(DiscoveryEvent ev){ ServiceRegistrar[] newregs = ev.getRegistrars(); for (int i=0;i<newregs.length;i++){ lookForService(newRegs[i]); } public void discarded(DiscoveryEvent ev){} }

Client code public HelloWorldClient() throws IOException { Class[] types = {HelloWorldServiceInterface.class}; template = new ServiceTemplate(null,types, null); if (System.getSecurityManager() == null) { System.setSecurityManager( new RMISecurityManager()); }

Client code // only search the public group disco = new LookupDiscovery(new String[] {“”}); //install a listener disco.addDiscoveryListener(new Listener()); // end of HelloWorldClient }

Look for proxies protected Object lookforService(ServiceRegistrar lusvc) { Object o = null; try { o = lusvc.lookup(template); } catch (RemoteException ex) { System.err.println(“Error doing”+ “lookup: ”+ex.getMessage()); return null; }

Look for proxies if (o==null) { System.err.println(“No matching”+ “service”); return null; } System.out.println(“Got a matching”+ ”service”); System.out.println(“It’s message is “+ ((HelloWorldServiceInterface) o).getMessage()); return o; }

Client, cont’d // client needs a thread “run” exactly // like server, to keep JVM alive public void run() { while (true) {.... //method to start the thread for clent public static void main(String args[]) { try { HelloWorldClient hwc = new HelloWorldClient(); new Thread(hwc).start; } catch (IOException ex) { System.out.println(“Couldn’t create cli:”+ ex.getMessage()); }}}