136
Dis papa, c’est quoi un bus logiciel r´ eparti ? [email protected] LIFL – IRCICA Equipe GOAL Octobre 2006 10. Des sockets aux bus logiciels r´ epartis

Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

Dis papa, c’est quoi un bus logiciel reparti ?

[email protected]

LIFL – IRCICAEquipe GOAL

Octobre 2006

10. Des sockets aux bus logiciels repartis

Page 2: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

1

0. Une application repartie

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 3: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

2

Objectif

√Decouvrir la notion et l’architecture d’un bus logiciel reparti, enconcevant un petit bus simple from scratch.

√Construire un bus logiciel en 10 etapes :I Chaque etape est un raffinement de la precedenteI Etape i + 1 = meilleure structuration de l’etape i

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 4: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

3

Les services

√Service 1 : Hello worldI Une methode hello avec un parametre de type chaıne

et retourne une chaıne : ”hello, ” + parametreI Deux methodes lower et upper qui retournent le parametre de type chaıne

en minuscule ou majuscules

√Service 2 : Nombres premiersI Calcule si un nombre est premier et retourne un booleenI Calcule le carre d’un nombre passe en parametreI Calcule la division de deux nombres passes en parametre

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 5: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

4

1. Au debut etait la socket

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 6: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

5

Principe

√Deux programmes ecrits en deux classes JavaI Une pour le serveur Server.javaI Une pour le client Client.java

√Dans chaque classe est implementeI Le code fonctionnel : manipulation des chaınesI Le code technique : construction / analyse des messages reseau

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 7: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

6

Architecture version 1

Client

Réseau

Server

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 8: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

7

Interactions version 1

ServantServerClient

connect ()

send (request)send (response)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 9: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

8

Cote serveur

√Initialisation du reseauI Instanciation d’une socket serveur

√Gestion des requetesI Attente de connexion (accept)I Initialisation des flux d’entree et de sortieI Evaluation des requetes• Lecture de la requete sur le flux d’entree• Creation de la chaıne a retourner• Ecriture de la reponse sur le flux de sortie

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 10: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

9

Code serveur (i)

package step1 ;import java.io.* ;import java.net.* ;public class Server {private ServerSocket asock ;

public Server () throws Exception {this.asock = new ServerSocket (12345) ;

}

public static void main (String args[]) {Server s = new Server () ;s.run () ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 11: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

10

Code serveur (ii)

public void run () throws Exception {while (true) {Socket sock = this.asock.accept () ;BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream ()));

DataOutputStream out =new DataOutputStream (sock.getOutputStream ());

String msg = in.readLine () ;String res = "Hello, " + msg + "\n" ; // fonctionnelout.writeBytes (res) ;

}}

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 12: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

11

Cote client

√Initialisation du reseauI Instanciation d’une socket de communication (connexion implicite)

√Gestion de l’echange reseauI Initialisation des flux d’entree et de sortieI Demande de service• Ecriture de la requete sur le flux de sortie• Lecture de la reponse sur le flux entree• Affichage de la chaıne retournee

I Fermeture de la connexion

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 13: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

12

Code client (i)

package step1 ;import java.io.* ;import java.net.* ;public class Client {private Socket sock ;public Client () throws Exception {this.sock = new Socket ("localhost", 12345) ;

}

public static void main (String args[]) throws Exception {Client c = new Client () ;c.run (args[0]) ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 14: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

13

Code client (ii)

public void run (String msg) throws Exception {BufferedReader in = new BufferedReader(new InputStreamReader(this.sock.getInputStream ()));

DataOutputStream out =new DataOutputStream (this.sock.getOutputStream ());

out.writeBytes (msg + "\n") ;String res = in.readLine () ;System.out.println ("Server replied: " + res) ;this.sock.close();

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 15: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

14

Benefices et limitations

√BeneficesI Invocation d’un service distant (hello world)I Permet de realiser des applications client / serveur

√LimitationsI Une seule connexion cliente a la foisI Beaucoup de code tres technique / peu de code metier

(40 lignes de code technique pour une ligne de code metier)I Un beau plat de spaghetti, non objet et difficilement evolutif

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 16: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

15

2. Gestionnaire de connexions

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 17: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

16

Principe

√Du cote serveurI Etablissement de la connexion par le serveur (accept)I La gestion de la connexion est delegueeI Apparition d’un objet Manager qui gere une connexion

√Du cote clientI Rien ne change pour le momentI Reutilisation du client de l’etape 1

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 18: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

17

Architecture version 2

Client

Réseau

Manager

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 19: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

18

Interactions version 2

send (request)

ServantServerClient

connect ()

Manager

process (sock)

create ()

send (response)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 20: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

19

Cote serveur (Serveur)

√IntialisationI De la socket d’administration / serveurI Creation d’un manager de connexions

√Gestion des requetesI Attente de connexionI Delegation au manager

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 21: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

20

Cote serveur (Manager)

√InitialisationI Rien de special

√Gestion des requetesI Initialisation du flux d’entree et de sortieI Evaluation de la requete• Lecture de la requete sur le flux entree• Creation de la chaıne a retourner• Ecriture de la reponse sur le flux de sortie

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 22: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

21

Code Serveur (i)

package step2 ;import java.io.*;import java.net.*;public class Server {private ServerSocket asock ;private Manager mgr ;

public Server () throws Exception {this.asock = new ServerSocket (12345) ;this.mgr = new Manager () ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 23: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

22

Code Serveur (ii)

public void run () throws Exception {while (true) {Socket sock = this.asock.accept () ;

this.mgr.process (sock) ;}

}

public static void main(String argv[]) throws Exception {Server s = new Server () ;s.run () ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 24: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

23

Code Manager

package step2 ;import java.io.* ;import java.net.* ;public class Manager {public Manager () throws Exception {}public void process (Socket sock) throws Exception {BufferedReader in = ...DataOutputStream out = ...

String msg = in.readLine () ;String res = "Hello, " + msg + "\n" ;out.writeBytes (res) ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 25: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

24

Benefices et limitations

√BeneficesI Ebauche de structurationI Distinction entre etablir une connexion et la gerer

√LimitationsI Le manager ne sait repondre qu’a une invocationI Le code n’est pas encore objet (i.e. le service)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 26: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

25

3. Decodage des requetes

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 27: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

26

Principe

√Cote serveurI Le manager propose plusieurs servicesI Le manager gere plusieurs requetes par connexion

√Cote clientI Utilise les services sequentiellementI Realise plusieurs invocations avec la meme connexion

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 28: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

27

Architecture version 3

Client

Réseau

Manager

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 29: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

28

Interactions version 3

send (response)send (request)

send (response)send (request)

send (response)send (request)

ServantServerClient

connect ()

Manager

process (sock)

create ()

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 30: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

29

Cote serveur

√Gestion des requetes par le ManagerI Initialisation des flux d’entree et de sortieI Evaluation de la requete• Lecture de la requete sur flux d’entree• Decodage de la requete (quel service ?)

requete = numero de service + arguments• Evaluation du service demande• Ecriture de la reponse sur flux de sortie

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 31: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

30

Code Manager (i)

public void process (Socket sock) throws Exception {BufferedReader in = ...DataOutputStream out = ...

while (true) {String msg = in.readLine () ;if (msg == null) // end of client connexionbreak ;

String res ;

switch (msg.charAt (0)) {

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 32: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

31

Code Manager (ii)

case ’0’:res = "hello, " + msg.substring (1) + "\n" ;break ;

case ’1’:res = msg.substring (1) .toLowerCase () + "\n" ;break ;

case ’2’:res = msg.substring (1) .toUpperCase () + "\n" ;break ;

default:res = "Unknown operation requested" ;

}out.writeBytes (res) ;

} }

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 33: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

32

Cote client

√Initialisation du reseauI Instanciation de la socket de communication

√Gestion des echanges reseauxI Intialisation des flux d’entree et de sortieI Demande de service (x3)• Requete reseau = numero de service + arguments• Ecriture requete, lecture reponse et affichage

I Fermeture de la connexion

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 34: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

33

Code Client (i)

public void run (String msg) throws Exception {BufferedReader in = ...DataOutputStream out = ...

String res ;

out.writeBytes ("0" + msg + "\n") ;res = in.readLine () ;System.out.println ("Server replied (hello): " + res) ;

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 35: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

34

Code Client (ii)

out.writeBytes ("1" + msg + "\n") ;res = in.readLine () ;System.out.println ("Server replied (lower): " + res) ;

out.writeBytes ("2" + msg + "\n") ;res = in.readLine () ;System.out.println ("Server replied (upper): " + res) ;

this.sock.close();}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 36: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

35

Benefices et limitations

√BeneficesI Un seul serveur propose plusieurs servicesI Utilisation d’une seule connexion par client

√LimitationsI Le code du service n’est toujours pas objetI Le code client est toujours un plat de spaghetti

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 37: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

36

4. Passage a un service objet

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 38: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

37

Principe

√Cote serveurI Le service est implemente comme un objet : le ServantI Le manager est dedie au reseau• decode les requetes• invoque le Servant

√Cote clientI Rien ne change

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 39: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

38

Architecture version 4

ServantClient

Réseau

Manager

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 40: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

39

Interactions version 4

ServantServerClient

create ()

connect ()

hello (str)

send (response)

send (request)

Manager

create (servant)

process (sock)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 41: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

40

Cote serveur

√Initialisation du Manager dans le serveurI Passage du Servant comme parametre

√Gestion des requetes par le ManagerI Initialisation des fluxI Evaluation des requetes• lecture et decodage de la requete• invocation du Servant• ecriture de la reponse

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 42: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

41

Code Server

public class Server {

private ServerSocket asock ;private Manager mgr ;

public Server () throws Exception {this.asock = new ServerSocket (12345) ;this.mgr = new Manager (new Servant ()) ;

}// unchanged

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 43: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

42

Code Servant

public class Servant {public String hello (String msg) {return "hello, " + msg ;

}public String lower (String msg) {return msg.toLowerCase () ;

}public String upper (String msg) {return msg.toUpperCase () ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 44: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

43

Code Manager (i)

public class Manager {private Servant ref ;public Manager (Servant s) throws Exception {this.ref = s ;

}public void process (Socket sock) throws Exception {BufferedReader in = ...DataOutputStream out = ...while (true) {String msg = in.readLine () ;if (msg == null) // no more to be readbreak ;

String res ;switch (msg.charAt (0)) {

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 45: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

44

Code Manager (i)

case ’0’:res = this.ref.hello (msg.substring (1)) + "\n" ;break ;

case ’1’:res = this.ref.lower (msg.substring (1)) + "\n" ;break ;

case ’2’:res = this.ref.upper (msg.substring (1)) + "\n" ;break ;

default:res = "Unknown operation requested" ;

}out.writeBytes (res) ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 46: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

45

Benefices et limitations

√BeneficesI Decouplage complet entre code technique et code metier (cote serveur)I Les services sont implantes comme des objets (Servant)

√LimitationsI L’interface du service n’est pas connue comme telle du clientI Le code client n’est toujours pas objet

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 47: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

46

5. Passage a l’objet du cote client

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 48: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

47

Principe

√Cote serveurI Definition d’un contrat a partager avec le clientI Le servant implemente le contrat commun

√Cote clientI Utilisation d’un objet representant le service : Proxy• Meme interface que le service• Encapsule le code technique de gestion du reseau

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 49: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

48

Architecture version 5

ServantClient

Proxy

Réseau

ManagerContrat

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 50: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

49

Interactions version 5

ServantServerProxyClient

create ()

init () connect ()

hello (str)

hello (str)

send (message)

send (message)

return

Manager

create (servant)

process (sock)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 51: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

50

Cote serveur

√ModificationsI Definition d’un contrat de serviceI Le servant implemente le contrat de service

√Contrat de serviceI Definit toutes les methodes accessibles a distanceI Chaque methode peut lever une exception liee au reseau

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 52: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

51

Contrat de service

package step5 ;

interface Service {

public String hello (String msg) throws Exception ;

public String lower (String msg) throws Exception ;

public String upper (String msg) throws Exception ;}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 53: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

52

Modification du Servant

public class Servant implements Service {public String hello (String msg) throws Exception {return "hello, " + msg ;

}public String lower (String msg) throws Exception {return msg.toLowerCase () ;

}public String upper (String msg) throws Exception {return msg.toUpperCase () ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 54: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

53

Cote client

√Programme clientI Instancie un proxyI Invocation des methodes du proxy

√Mise en œuvre du ProxyI Implemente l’interface de contratI Initialise la connexion au serveurI Gere toute la partie echanges reseaux

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 55: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

54

Code du Client

public class Client {private Service ref ;

public Client () throws Exception {this.ref = (Service) new Proxy () ;

}public void run (String msg) throws Exception {System.out.println (this.ref.hello (msg)) ;System.out.println (this.ref.lower (msg)) ;System.out.println (this.ref.upper (msg)) ;

}// unchanged

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 56: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

55

Code du Proxy (i)

public class Proxy implements Service {private Socket sock ;private BufferedReader in ;private DataOutputStream out ;public Proxy () throws Exception {this.sock = new Socket ("localhost", 12345) ;this.in = ...this.out = ...

}public String hello (String msg) throws Exception {this.out.writeBytes ("0" + msg + "\n") ;String res = this.in.readLine () ;return res ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 57: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

56

Code du Proxy (ii)

public String lower (String msg) throws Exception {this.out.writeBytes ("1" + msg + "\n") ;String res = this.in.readLine () ;return res ;

}public String upper (String msg) throws Exception {this.out.writeBytes ("2" + msg + "\n") ;String res = this.in.readLine () ;return res ;

}protected void finalize () throws Throwable {this.sock.close () ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 58: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

57

Benefices et limitations

√BeneficesI Du point de vue du client la repartition est masqueeI Le service est vu et manipule comme un objet local

√LimitationsI Comment utiliser des parametres autres que de type StringI Comment designer un service distant (sans le coder en dur)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 59: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

58

6. Encodage et decodage des donnees

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 60: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

59

Principe

√Traduction des parametresI Empaquetage : application vers les messages reseau• type de base vers representation chaıne

I Depaquetage : messages reseau vers application• representation chaıne vers type de base

√Operations de traduction symetriquesI Serveur : depaquetage des parametres, empaquetages des valeurs de retourI Client : empaquetage des parametres, depaquetages des valeurs de retour

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 61: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

60

Architecture version 6

ServantClient

Proxy

Réseau

ManagerContrat

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 62: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

61

Interactions version 6

ServantServerProxyClient

create ()

init () connect ()

sqr (val)marshal ()

sqr (val)

send (message)

send (message)

unmarshall ()return

Manager

create (servant)

process (sock)

unmarshall ()

marshall ()

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 63: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

62

Cote serveur

√Modification du contrat de serviceI Offre une operation supplementaireI Calcul du carre d’un entier (retourne un entier)

√Modification de la mise en œuvreI Manager : message reseau supplementaire et decodage entierI Servant : implementation de la nouvelle methode

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 64: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

63

Contrat Service

interface Service {

public String hello (String msg) throws Exception ;

public String lower (String msg) throws Exception ;

public String upper (String msg) throws Exception ;

public int sqr (int a) throws Exception ;}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 65: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

64

Code Manager

public void process (Socket sock) throws Exception {// unchangedswitch (msg.charAt (0)) {// unchanged for 0-2case ’3’:int val = Integer.parseInt (msg.substring (1)) ;res = "" + this.ref.sqr (val) + "\n" ;break ;

default:res = "Unknown operation requested" ;

}out.writeBytes (res) ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 66: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

65

Code Servant

public class Servant implements Service {

// unchanged

public int sqr (int val) throws Exception {return val * val ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 67: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

66

Cote client

√Modification de la mise en œuvreI Le proxy implemente la nouvelle operationI Le programme client utilise la nouvelle operation

√Mise en œuvre du ProxyI Empaquetage de l’entier parametre dans une chaıneI Depaquetage de l’entier contenu dans la chaıne retour

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 68: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

67

Code Proxy

public class Proxy implements Service {

// unchanged

public int sqr (int val) throws Exception {this.out.writeBytes ("3" + val + "\n") ;String res = this.in.readLine () ;return Integer.parseInt (res) ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 69: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

68

Code Client

public class Client {

// unchanged

public void run (String msg) throws Exception {System.out.println (this.ref.hello (msg)) ;System.out.println (this.ref.lower (msg)) ;System.out.println (this.ref.upper (msg)) ;int res = this.ref.sqr (123) ;System.out.println (res) ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 70: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

69

Benefices et limitations

√BeneficesI Utilisation transparente des types de base autres que StringI Vision objet d’une application repartie

√LimitationsI Comment designer un service distant sans le coder en durI Comment ecrire un client pouvant utiliser plusieurs services

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 71: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

70

7. Notion de reference distante

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 72: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

71

Principe

√Designation d’un service distantI Equivalent a une reference Java mais en repartiI Permet d’etablir une connexion avec un service

√Definition d’une reference (base)I Hote distant : adresse IPI Serveur distant : port IP

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 73: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

72

Architecture version 7

ServantClient

Proxy

Réseau

ManagerContrat

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 74: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

73

Interactions version 7

ServantServerProxyClient

create ()

init () connect ()

hello (str)marshal ()

hello (str)

send (message)

send (message)

unmarshall ()return

Manager

create (servant)

process (sock)

unmarshall ()

marshall ()

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 75: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

74

Cote client

√Fourniture de la reference du serveurI Propriete java contenant la referenceI Reference donnee sous la forme machine:port

√Ajout d’un methode de gestion des referencesI Analyse la referenceI Instancie et initialise le Proxy d’acces au service

# utilisation avec une reference> java -Dservice.reference=localhost:12345 \step7.Client DrNo

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 76: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

75

Code Client

public class Client {

private Service ref ;

public Client () throws Exception {this.ref = (Service) this.ref2proxy () ;

}

// other methods unchanged

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 77: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

76

Code Client

public Proxy ref2proxy () throws Exception {Properties props = System.getProperties () ;String ref = props.getProperty ("service.reference") ;if (ref == null)throw new Exception ("no server reference given") ;

String parts[] = ref.split (":") ;if (parts.length < 2)throw new Exception ("malformed reference") ;

String host = parts [0] ;int port = Integer.parseInt (parts [1]) ;return new Proxy (host, port) ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 78: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

77

Benefices et limitations

√BeneficesI Le code client n’est pas lie a une instance de serveurI Possibilite d’utiliser differents serveurs

√LimitationsI Un seul objet service par serveurI Un client ne peut utiliser qu’un objet a la foisI Le client doit connaıtre le type de la reference a la compilation

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 79: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

78

8. Notion d’adaptateur d’objet

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 80: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

79

Principe

√Rendre plusieurs objets (Servant) disponibles dans un serveurI Chaque objet est associe a une cle unique dans le serveurI Un reference inclut desormais la cle de l’objet

√Adaptateur d’objetI Aiguillage et lien entre le reseau et les objetsI Gere les cles associees aux objets et leurs referencesI Raffinement du Manager• Adaptateur : lien reference / objet d’implementation• Squelette : decodeur de requete pour un objet

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 81: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

80

Architecture version 8

Skeleton

ObjectAdapter

Servant ServantClient

Proxy

Réseau

Skeleton

Contrat

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 82: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

81

Interactions version 8

AdapterObject

Skeleton ServantServerProxyClientinit ()

create ()

create (servant)

register (skel)

init () connect ()process ()

run (sock)

hello (str)marshal ()

unmarshall ()

hello (str)

marshall ()send (message)

send (message)

unmarshall ()return

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 83: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

82

Cote serveur

√Adaptateur d’objetI Gestion du accept et du routage des requetesI Connecte les objets et cree leurs references√Squelette de serviceI Defini par rapport au contrat de ServantI Decodeur de messages reseau pour un Servant particulierI Definition de deux squelettes√Programme serveurI Cree un adaptateur d’objetI Cree deux squelettes et servants, les enregistreI Active l’adaptateur d’objet

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 84: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

83

Contrats

interface ServiceA {public String hello (String msg) throws Exception ;public String lower (String msg) throws Exception ;public String upper (String msg) throws Exception ;

}

interface ServiceB {public boolean isprime (int a) throws Exception ;public int sqr (int a) throws Exception ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 85: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

84

Code Server

public class Server {public void run () throws Exception {ObjectAdapter oa = ObjectAdapter.init () ;

SkeletonA skel_a = new SkeletonA (new ServantA ()) ;oa.register (skel_a) ;System.out.println (oa.obj2ref (skel_a)) ;

SkeletonB skel_b = new SkeletonB (new ServantB ()) ;oa.register (skel_b) ;System.out.println (oa.obj2ref (skel_b)) ;

oa.start () ;} // rest is unchanged

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 86: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

85

Code ObjectAdapter (i)

public class ObjectAdapter extends Thread {private static ObjectAdapter ref ;private ServerSocket asock ;private Vector skeletons ;protected ObjectAdapter () throws Exception {this.skeletons = new Vector () ;this.asock = new ServerSocket (0) ;

}public static ObjectAdapter init () throws Exception {if (ObjectAdapter.ref == null)ObjectAdapter.ref = new ObjectAdapter () ;

return ObjectAdapter.ref ;}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 87: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

86

Code ObjectAdapter (ii)

public String obj2ref (Skeleton obj) {int key = this.skeletons.indexOf (obj) ;if (key == -1)return null ;

String host = null ;try {host = InetAddress.getLocalHost () .getHostAddress () ;

} catch (UnknownHostException uhe) {return null ;

}int port = this.asock.getLocalPort () ;return host + ":" + port + ":" + key ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 88: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

87

Code ObjectAdapter (iii)

public void run () {try {while (true) {Socket sock = this.asock.accept () ;BufferedReader in = ...String msg = in.readLine () ;if (msg == null) { // no more to be read

sock.close () ;continue ;

}int key = Integer.parseInt (msg.substring (0,1)) ;

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 89: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

88

Code ObjectAdapter (iv)

try {Skeleton skel =

(Skeleton)this.skeletons.elementAt (key) ;skel.init (sock) ;new Thread (skel) .start () ;

} catch (ArrayIndexOutOfBoundsException e) {sock.close () ;

}}

} catch (Exception e) {return ;

}}

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 90: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

89

Interface Skeleton

interface Skeleton extends Runnable {void init (Socket sock) throws Exception ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 91: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

90

Code SkeletonA (i)

public class SkeletonA implements Skeleton {private ServantA ref ;

public SkeletonA (ServantA s) throws Exception {this.ref = s ;

}

public void init (Socket sock) throws Exception {this.in = ...this.out = ...

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 92: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

91

Code SkeletonA (ii)

public void run () {try {while (true) {String msg = this.in.readLine () ;if (msg == null) // no more to be read

break ;String res ;switch (msg.charAt (0)) {case ’0’:res = this.ref.hello (msg.substring (1)) + "\n" ;break ;

// etc.}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 93: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

92

Cote client

√Modification du proxyI Prise en compte des cles d’objetsI Connexion en deux temps au squelette

√Definition d’un Proxy pour chacun des servicesI Deux chaınes Proxy / Skeleton / ServantI Fourniture de la reference comme une propriete

√Definition de deux programes clientsI Chacun utilise un proxy pour un service particulier

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 94: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

93

Code ProxyA (changes)

public class ProxyA implements ServiceA {private Socket sock ;private BufferedReader in ;private DataOutputStream out ;

public ProxyA (String host, int port, String key)throws Exception {

this.sock = new Socket (host, port) ;this.in = ...this.out = ...

this.out.writeBytes (key + "\n") ;}

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 95: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

94

Code ClientA (changes i)

public class ClientA {private ServiceA ref ;

public ClientA () throws Exception {this.ref = (ServiceA) this.ref2proxy () ;

}public void run (String msg) throws Exception {System.out.println (this.ref.hello (msg)) ;System.out.println (this.ref.lower (msg)) ;System.out.println (this.ref.upper (msg)) ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 96: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

95

Code ClientA (changes ii)

public ProxyA ref2proxy () throws Exception {Properties props = System.getProperties () ;String ref = props.getProperty ("service.reference") ;if (ref == null)throw new Exception ("no server reference given") ;

String parts[] = ref.split (":") ;if (parts.length < 3)throw new Exception ("malformed reference") ;

String host = parts [0] ;int port = Integer.parseInt (parts [1]) ;String key = parts [2] ;return new ProxyA (host, port, key) ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 97: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

96

Benefices et limitations

√BeneficesI Serveur multi-services et multi-threade (Skeleton)I Identification complete d’un service – adresse:port:cle

I Les references sont creees au niveau du serveur

√LimitationsI Comment definir et utiliser des exceptions applicatives ?I Comment simplifier la traduction de reference en Proxy

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 98: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

97

9. Exceptions et traduction reference vers Proxy

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 99: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

98

Principe

√ExceptionsI Ajout d’un code dans les messages de retourI 0 : OK ; sinon un numero d’exception...

√Traduction automatique de references en ProxyI Extension des references pour contenir le type des referencesI Controle du typage lors de la creation du proxyI Instanciation et initialisation automatique du Proxy

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 100: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

99

Architecture version 9

Skeleton

ObjectAdapter

Servant ServantClient

Proxy

Réseau

Skeleton

Contrat

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 101: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

100

Interactions version 9

AdapterObject

Skeleton ServantServerProxyClientinit ()

create ()

create (servant)

register (skel)

init () connect ()process ()

run (sock)

hello (str)marshal ()

unmarshall ()

hello (str)

marshall ()send (message)

send (message)

unmarshall ()return

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 102: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

101

Chargement automatique de proxy

√MotivationsI Transformation d’une reference de service distant en proxyI Controler la conformite entre le type du proxy et du service

√Modifications des implementationsI Extension des references• Ajout du type du service dans la reference : adresse:port:cle:type

I Regles de nommage des classes• NomDuServiceProxy, NomDuServiceSkeleton, NomDuServiceServant• Les squelettes fournissent le type du service (pour construire la reference)

I Interface de base Proxy implementee par tous les proxy (pour init)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 103: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

102

Operation ref2proxy (i)

public class Util {public static Proxy ref2proxy (String ref)throws Exception {

String parts[] = ref.split (":") ;if (parts.length < 4)throw new Exception ("malformed reference") ;

String host = parts [0] ;int port = Integer.parseInt (parts [1]) ;String key = parts [2] ;String type = parts [3] ;

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 104: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

103

Operation ref2proxy (ii)

// instanciation du bon proxy (present dans classpath)Class pclass = Class.forName (type + "Proxy") ;Proxy p = (Proxy) pclass.newInstance () ;

// initialisationp.init (host, port, key) ;return p ;

}}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 105: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

104

Cote serveur

√Gestion des exceptionsI Definition des exceptions dans le contrat du serviceI Modification des squelettes pour transferer les exceptions• Ajout de try catch pour les exceptions applicatives• Ajout d’un code en debut de message reponse reseau

√Typage des referencesI Modification des squelettes : fourniture du type du servantI Modification de l’operation obj2ref dans l’adapteur d’objet

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 106: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

105

Contrat ServiceB

public class DivByZero extends Exception {}

interface ServiceB {public boolean isprime (int a)throws Exception ;

public int sqr (int a)throws Exception ;

public int div (int a, int b)throws Exception, DivByZero ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 107: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

106

Interface Skeleton

interface Skeleton extends Runnable {

void init (Socket sock) throws Exception ;

String type () ;}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 108: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

107

Code ServiceBSkeleton (changes i)

public String type () {return "step9.ServiceB" ;

}

public void run () {// unchanged

// managing isprime method from ServiceBcase ’0’:

int val0 = Integer.parseInt (msg.substring (1)) ;res = "0" + this.ref.isprime (val0) + "\n" ;break ;

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 109: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

108

Code ServiceBSkeleton (changes ii)

// managing div method from ServiceBcase ’2’:String args [] = msg.substring (1) .split (" ") ;int arg0 = Integer.parseInt (args [0]) ;int arg1 = Integer.parseInt (args [1]) ;try {

res = "0" + this.ref.div (arg0,arg1) + "\n" ;} catch (DivByZero e) {

res = "1\n" ; // first exception raised}break ;

// etc.}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 110: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

109

Code ObjectAdapter

public String obj2ref (Skeleton obj) {int key = this.skeletons.indexOf (obj) ;if (key == -1) return null ;String host = null ;try {host = InetAddress.getLocalHost () .getHostAddress () ;

} catch (UnknownHostException uhe) {return null ;

}int port = this.asock.getLocalPort () ;return host + ":" + port + ":" + key + ":" + obj.type () ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 111: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

110

Cote client

√Modification des proxyI Gestion des exceptionsI Si code interne superieur a 0 alors lever l’exception equivalente

√Modification des clientsI Utilisation de l’operation ref2proxyI Plus besoins preciser le nom du ProxyI Utiliser le proxy avec le type de son interface

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 112: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

111

Code ServiceBProxy (changes i)

public boolean isprime (int val) throws Exception {// automatic conversion of int to stringout.writeBytes ("0" + val + "\n") ;String res = in.readLine () ;return Boolean.valueOf (res.substring (1))

.booleanValue () ;}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 113: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

112

Code ServiceBProxy (changes ii)

public int div (int a, int b)throws Exception, DivByZero {

out.writeBytes ("2" + a + " " + b + "\n") ;String res = in.readLine () ;if (res.charAt (0) == ’1’)throw new DivByZero () ;

return Integer.parseInt (res.substring (1)) ;}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 114: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

113

Code ClientB (changes)

public ClientB () throws Exception {Properties props = System.getProperties () ;String ref = props.getProperty ("service.reference") ;

this.refB = (ServiceB) Util.ref2proxy (ref) ;}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 115: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

114

Benefices et limitations

√BeneficesI Benefices des exceptions sur le code produitI Controle du typage a l’utilisation des references

√LimitationsI Partage des references complique et reduit au fichierI Utiliser facilement plusieurs services dans un meme client ?

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 116: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

115

10. Service de designation

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 117: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

116

Principe

√Designation des objets par des noms symboliques

√Association : nom symbolique / referencesI Les serveurs enregistrent une reference avec un nomI Les clients recherchent une reference avec un nom

√Service notoire : l’annuaire

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 118: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

117

Architecture version 10

Client

Proxy

Réseau

Contrats

Skeleton

OAdapt

Skeleton

OAdapt

ServantServantNaming Service

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 119: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

118

Interactions version 10 (*)

NameServerClient

init () connect ()

Proxy ProxyNaming Service

ProxyNaming

Server Service

bind (ref)send (message)

lookup () send (message)

ref2proxy ()

hello (str)

connect ()

send (message)

send (message)return

init ()connect ()

create ()

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 120: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

119

Annuaire

√Service au meme titre qu’un autreI Defini par une interfaceI Heberge par un serveurI Accessible au travers d’un Proxy

√ParticularitesI Serveur dedie initialise sur un port predefini• Connaıtre la machine = point d’entree du systeme

I Proxy particulier pour simplifier l’utilisation• Patron de conception Singleton

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 121: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

120

Contrat NameService

interface NameService {

public void export (String name, String ref)throws Exception ;

public String lookup (String name)throws Exception ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 122: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

121

Proxy Naming (extrait)

public class Naming {private static Naming ref ;private Naming () throws Exception {Properties props = System.getProperties () ;String host = props.getProperty ("naming.host") ;// etc.

}public static Naming init () throws Exception {if (Naming.ref == null)Naming.ref = new Naming () ;

return Naming.ref ;// etc.

} // etc.}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 123: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

122

Cote serveur

√Diffusion des referencesI Plus d’affichage sur la ligne de commandeI Export des references de services

√Vers une application repartieI Le serveur est client du service de nommageI Utilisation du proxy de ce dernier

√Unique point d’entree : reference du service de nommage

$ java -Dnaming.host=localhost step9.Server

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 124: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

123

Code Server (changes)

public void run () throws Exception {Naming ns = Naming.init () ;ObjectAdapter oa = ObjectAdapter.init () ;

ServiceASkeleton skel_a =new ServiceASkeleton (new ServiceAServant ()) ;

oa.register (skel_a) ;ns.export ("ServiceA", oa.obj2ref (skel_a)) ;ServiceBSkeleton skel_b =new ServiceBSkeleton (new ServiceBServant ()) ;

oa.register (skel_b) ;ns.export ("ServiceB", oa.obj2ref (skel_b)) ;oa.run () ;

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 125: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

124

Cote client

√Recuperation des referencesI Plus de lecture de fichiers texteI Lookup des references de service

√Vers une application repartieI Client est client des services A, B et NommageI Utilisation des proxy de ces trois services

√Unique point d’entree : reference du service de nommage

$ java -Dnaming.host=localhost step9.Client

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 126: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

125

Code Client (changes)

public class Client {public Client () throws Exception {Naming ns = Naming.init () ;

String ref_a = ns.lookup ("ServiceA") ;this.refA = (ServiceA) Util.ref2proxy (ref_a) ;

String ref_b = ns.lookup ("ServiceB") ;this.refB = (ServiceB) Util.ref2proxy (ref_b) ;

}// merge of previous clients’ code

}

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 127: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

126

Benefices et limitations

√BeneficesI Unique point d’entree dans le systemeI Partage simplifie des references de services

√LimitationsI On ecrit un peu toujours la meme chose...I On risque a chaque fois de faire des erreurs (skel/proxy)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 128: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

127

11. Generation automatique du code technique

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 129: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

128

Principe

√Presentation des motivationsI On ne va pas toujours ecrire la meme choseI Un proxy et un squelette suivent toujours le meme schema

√Quelques mises en œuvre possiblesI Generateur reflexif (par rapport aux interfaces Java)• Realisation uniforme (mono-langage)• Implementation assez technique

I Generation par rapport a des contrats XML• Implementation relativement directe (DOM)• Permet de gerer plusieurs langages cibles

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 130: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

129

Regles de generation

√Un contrat de service XXX devient 3 classesI XXXProxy• Une methode init pour la connexion• Une methode par methode du contrat

I XXXSkeleton• Une methode run avec un switch• Une entree par methode du contrat

I XXXServant• Les methodes du contrat a completer

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 131: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

130

Benefices et limitations

√BeneficesI Contrat + generateur ⇒ Proxy, Skeleton, ServantI Il ne reste plus qu’a ecrire le code fonctionnel

√LimitationsI Ce n’est toujours pas parfait : implementation basique• Passage de references d’objets distants ?• Passage d’objets serialises ?

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 132: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

131

Remarques et conclusions

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 133: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

132

Remarques

√Progressivement nous venons de definir un bus logicielI Sa structurationI Son utilisation

√Un bus logiciel repose essentiellement sur deux conceptsI La designation d’un service (les references)I La liaison avec un service distant (etablir une connexion)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 134: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

133

Architecture generale d’un bus logiciel

Client

Proxy

Réseau

Contrats

Skeleton

OAdapt

Skeleton

OAdapt

ServantServantNaming Service

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 135: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

134

Conclusion

√BeneficesI Abstraction de la preoccupation communication d’une applicationI Generation du code technique de la preoccupation automatisable

√Et maintenant ?I Raffiner le code pour l’optimiser et le rendre plus fiable• meilleure structuration des messages reseau (definition d’un protocole)• depasser la limitation de 10 methodes par interface• permettre le passage de types complexex et references en parametres

I Developpement de services de base (comme l’annuaire)

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie

Page 136: Raphael.Marvie@lifl - FIL Lille 1marvie/download/IntroBu... · 2007-05-30 · 2 Objectif √ Decouvrir la notion et l’architecture d’un´ bus logiciel reparti, en´ concevant

135

Dis papa, c’est quoi cette bouteille de lait ?

10. Des sockets aux bus logiciels repartis c© 2003 - 2006, Raphael Marvie