Etude de cas d'une application CCM

Download Report

Transcript Etude de cas d'une application CCM

ICAR’03
École d’été sur les Intergiciels et
sur la Construction d’Applications Réparties
Etude de cas d’une application
construite avec CCM
Philippe Merle
Projet Jacquard (INRIA et LIFL)
http://www.lifl.fr/~merle
L’application du dîner des
philosophes
Thinking
Hungry
Starving
Eating
Dead
Fork
Thinking
Hungry
Starving
Eating
Dead
Descartes
Kant
Fork
Fork
Aristotle
© 2003, P. Merle
ICAR’03
Thinking
Hungry
Starving
Eating
Dead
2
L’application à l’exécution
Node 1
Node 2
Node 3
Node 4
Node 5
© 2003, P. Merle
ICAR’03
3
Plan
 La conception des composants CORBA
 Notations : graphique, profile UML 1.x pour CCM et OMG IDL 3.0
 L’utilisation des composants CORBA
 Projection OMG IDL 3.0 vers OMG IDL ; code client
 Le développement des composants CORBA
 Notation OMG CIDL ; classes Java d’implantation
 Le conditionnement et l’assemblage des composants CORBA
 Notation XML CCM ; exemples d’outils
 Le déploiement, l’exécution et l’administration de l’application
 Démonstration sur la plate-forme OpenCCM
 Conclusion
© 2003, P. Merle
ICAR’03
4
La conception des
composants CORBA
© 2003, P. Merle
ICAR’03
5
La conception des
composants CORBA
 Concevoir des composants CORBA = identifier les
 Types de composants et leurs ports
 Interfaces et événements d’interaction (~ typage des ports)
 Types de maisons de composants et leurs opérations
 Types de données et exceptions utilitaires
 Via une notation
 Graphique informelle
 Profil UML 2.0 pour CCM (non existant)
 Profil UML 1.x pour CCM (en cours de standardisation OMG)
 OMG IDL 3.0 défini dans CORBA 3.0
 Cependant une plate-forme CCM « classique » ne comprend que
la notation OMG IDL 3.0
 Toutefois OpenCCM compile aussi des fichiers XMI UML CCM
© 2003, P. Merle
ICAR’03
6
Le dîner des philosophes
notation graphique informelle
Composant
Philosopher
Interf. base
Facette
Fork
Réceptacle
name = Kant
Puit évén.
Fork
Source évén.
Philosopher
Fork
name = Descartes
Philosopher
name = Aristotle
© 2003, P. Merle
Observer
ICAR’03
7
Des outils pour la conception
des composants CORBA
Concepteur
Composant
Atelier UML
IDE
Rose, Poseidon, Objecteering
Eclipse, NetBeans
XMI UML CCM
N’importe quel
éditeur de texte
OMG IDL 3.0
Plate-forme CCM
© 2003, P. Merle
ICAR’03
8
L’atelier Cadena
Plug-in Eclipse + OpenCCM
© 2003, P. Merle
ICAR’03
9
L’atelier Objecteering
avec profil UML pour CCM
 Développement LIFL dans projet RNTL ACCORD
© 2003, P. Merle
ICAR’03
10
Le composant ForkManager
notation graphique informelle
Interface
de base
Interface
Fork
© 2003, P. Merle
facette
the_fork
Composant
ForkManager
ICAR’03
11
Le composant ForkManager
notation profil UML 1.x pour CCM
© 2003, P. Merle
ICAR’03
12
Le composant ForkManager
notation OMG IDL 3.0
exception InUse {};
interface Fork
{
void get() raises (InUse);
void release();
};
Fork
Manager
// Le composant fourchette.
component ForkManager
{
// La facette fourchette utilisée par les philosophes.
provides Fork the_fork;
};
© 2003, P. Merle
ICAR’03
13
Le composant ForkManager
notation OMG IDL 3.0
exception InUse {};
interface Fork
{
void get() raises (InUse);
void release();
};
Fork
Manager
// Le composant fourchette.
component ForkManager
{
// La facette fourchette utilisée par les philosophes.
provides Fork the_fork;
};
© 2003, P. Merle
ICAR’03
14
Le composant ForkManager
notation OMG IDL 3.0
exception InUse {};
interface Fork
{
void get() raises (InUse);
void release();
};
Fork
Manager
// Le composant fourchette.
component ForkManager
{
// La facette fourchette utilisée par les philosophes.
provides Fork the_fork;
};
© 2003, P. Merle
ICAR’03
15
La maison de ForkManager
selon les 3 notations
ForkHome
Fork
Manager
// OMG IDL 3.0
home ForkHome manages ForkManager {};
© 2003, P. Merle
ICAR’03
16
L’événement StatusInfo
notations UML / CCM et OMG IDL 3.0
enum PhilosopherState {
EATING, THINKING,
HUNGRY, STARVING, DEAD
};
eventtype StatusInfo {
public string name;
public PhilosopherState state;
public unsigned long
ticks_since_last_meal;
public boolean has_left_fork;
public boolean has_right_fork;
};
profil UML pour CCM
© 2003, P. Merle
OMG IDL 3.0
ICAR’03
17
Le composant Philosopher
notation graphique informelle
Réceptacle
Fork left
Composant
Philosopher
Réceptacle
Fork right
Source
StatusInfo info
Attribut name
© 2003, P. Merle
ICAR’03
18
Le composant Philosopher
notation profil UML 1.x pour CCM
© 2003, P. Merle
ICAR’03
19
Le composant Philosopher
notation OMG IDL 3.0
component Philosopher
{
attribute string name;
Philosopher
// La fourchette à gauche.
uses Fork left;
name = XXX
// La fouchette à droite.
uses Fork right;
// La source d’événements StatusInfo.
publishes StatusInfo info;
};
© 2003, P. Merle
ICAR’03
20
Le composant Philosopher
notation OMG IDL 3.0
component Philosopher
{
attribute string name;
Philosopher
// La fourchette à gauche.
uses Fork left;
name = XXX
// La fouchette à droite.
uses Fork right;
// La source d’événements StatusInfo.
publishes StatusInfo info;
};
© 2003, P. Merle
ICAR’03
21
Le composant Philosopher
notation OMG IDL 3.0
component Philosopher
{
attribute string name;
Philosopher
// La fourchette à gauche.
uses Fork left;
name = XXX
// La fouchette à droite.
uses Fork right;
// La source d’événements StatusInfo.
publishes StatusInfo info;
};
© 2003, P. Merle
ICAR’03
22
Le composant Philosopher
notation OMG IDL 3.0
component Philosopher
{
attribute string name;
Philosopher
// La fourchette à gauche.
uses Fork left;
name = XXX
// La fouchette à droite.
uses Fork right;
// La source d’événements StatusInfo.
publishes StatusInfo info;
};
© 2003, P. Merle
ICAR’03
23
La maison de Philosopher
selon les 3 notations
PhilosopherHome
Philosopher
name = XXX
// OMG IDL
home PhilosopherHome manages Philosopher {
factory new(in string name);
};
© 2003, P. Merle
ICAR’03
24
Le composant Observer
notation graphique informelle
Interface
de base
eventtype
StatusInfo
© 2003, P. Merle
Composant
Observer
Puit
info
ICAR’03
25
Le composant Observer
notation profil UML 1.x pour CCM
© 2003, P. Merle
ICAR’03
26
Le composant Observer
notation OMG IDL 3.0
Observer
component Observer
{
// Le puit de réception de StatusInfo.
consumes StatusInfo info;
};
© 2003, P. Merle
ICAR’03
27
Le composant Observer
notation OMG IDL 3.0
Observer
component Observer
{
// Le puit de réception de StatusInfo.
consumes StatusInfo info;
};
© 2003, P. Merle
ICAR’03
28
La maison de Observer
selon les 3 notations
Observer Home
Observer
© 2003, P. Merle
// OMG IDL
home ObserverHome
manages Observer {};
ICAR’03
29
L’utilisation des
composants CORBA
© 2003, P. Merle
ICAR’03
30
L’utilisation des composants CORBA
 « OMG IDL orienté composant » uniquement sucre syntaxique
pour décrire les composants CORBA, projeté en OMG IDL 2.x
 Chaque construction OMG IDL 3.0 a une équivalence en OMG IDL 2.x
 Une seule projection spécifiée au lieu d’une par langages de
programmation
 Préservation des standards de projection OMG IDL 2.x  langages
 Les composants et maisons sont utilisés par les développeurs
comme des objets CORBA étendus
 Composants et maisons invoqués comme des objets CORBA
 Applications clientes uniquement CORBA 2.x possible
 Préservation des compétences des développeurs CORBA 2.x
 Réutilisation des outils CORBA 2.x, e.g. générateurs de souches/squelettes
© 2003, P. Merle
ICAR’03
31
Le projection OMG IDL 3.0
vers OMG IDL 2.x
Code utilisateur
Utilisateur
Composant
Concepteur
Composant
Compilateur
Code généré
OMG IDL 3.0
Orienté
Composant
Application
Cliente
Utilise
OMG IDL 2.x
Orienté
Objet
Compilateur
OMG IDL 3.0
Implanté par
Souche
Cliente
© 2003, P. Merle
ORB
ICAR’03
Composant
32
Les principales règles de projection
OMG IDL 3.0 vers OMG IDL
 1 type de composants  1 interface
 héritant de Components::CCMObject
 1 propriété  1 attribut
 1 facette ou puits  1 opération fournissant la référence du port
 1 réceptacle  opérations de connexion, déconnexion et d’acquisition de la
(ou des) référence(s) associée(s)
 1 source  opérations de (dé)souscription aux événements produits
 1 type de maisons 3 interfaces
 1 pour opérations explicites du concepteur
 + héritage de Components::CCMHome
 1 pour opérations implicites générées
 1 héritant des 2 interfaces précédentes
 1 type d’événements  1 type de valeurs + 1 interface Consumer
 héritant de Components::EventBase
 héritant de Components::EventConsumerBase
© 2003, P. Merle
ICAR’03
33
La projection OMG IDL
du composant ForkManager
component ForkManager
{
provides Fork the_fork;
};
Fork
Manager
Traduit en
interface ForkManager :
::Components::CCMObject
{
Fork provide_the_fork();
};
© 2003, P. Merle
ICAR’03
34
La projection OMG IDL
de la maison ForkHome
home ForkHome
manages ForkManager {};
Traduit en
interface ForkHomeExplicit :
::Components::CCMHome {};
interface ForkHomeImplicit :
::Components::KeylessCCMHome {
ForkManager create();
};
interface ForkHome :
ForkHomeExplicit,
ForkHomeImplicit {};
© 2003, P. Merle
ICAR’03
ForkHome
Fork
Manager
35
La projection OMG IDL
de l’événement StatusInfo
eventtype StatusInfo { . . . };
Traduit en
valuetype StatusInfo :
::Components::EventBase { . . . };
interface StatusInfoConsumer :
::Components::EventConsumerBase {
void push_StatusInfo(in StatusInfo
the_StatusInfo);
};
© 2003, P. Merle
ICAR’03
36
La projection OMG IDL
du composant Observer
component Observer {
consumes StatusInfo info;
};
Observer
Traduit en
interface Observer :
::Components::CCMObject {
StatusInfoConsumer get_consumer_info();
};
© 2003, P. Merle
ICAR’03
37
La projection OMG IDL
de la maison ObserverHome
home ObserverHome
manages Observer {};
Observer Home
Traduit en
interface ObserverHomeExplicit :
::Components::CCMHome {};
interface ObserverHomeImplicit :
::Components::KeylessCCMHome {
Observer
Observer create();
};
interface ObserverHome :
ObserverHomeExplicit,
ObserverHomeImplicit {};
© 2003, P. Merle
ICAR’03
38
La projection OMG IDL
du composant Philosopher
component Philosopher {
attribute string name;
uses Fork left;
uses Fork right;
publishes StatusInfo info;
};
Philosopher
name = XXX
Traduit en
interface Philosopher :
::Components::CCMObject {
attribute string name;
.../...
© 2003, P. Merle
ICAR’03
39
La projection OMG IDL
du composant Philosopher
Traduit en
Philosopher
void connect_left(in Fork cnx) raises(…);
Fork disconnect_left() raises(…);
name = XXX
Fork get_connection_left();
void connect_right(in Fork cnx) raises (…);
Fork disconnect_right() raises (…);
Fork get_connection_right();
Components::Cookie subscribe_info(
in StatusInfoConsumer consumer) raises(…);
StatusInfoConsumer unsubscribe_info(
in Components::Cookie ck) raises(…);
};
© 2003, P. Merle
ICAR’03
40
La projection OMG IDL
de la maison PhilosopherHome
home PhilosopherHome
manages Philosopher {
factory new(in string name);
PhilosopherHome
Traduit en
};
interface PhilosopherHomeExplicit :
::Components::CCMHome {
Philosopher new(in string name);
Philosopher
name = XXX
};
interface PhilosopherHomeImplicit :
::Components::KeylessCCMHome {
Philosopher create();
};
interface PhilosopherHome :
PhilosopherHomeExplicit,
PhilosopherHomeImplicit {};
© 2003, P. Merle
ICAR’03
41
Le modèle de programmation
des clients
 Deux canevas de conception
 Factory – Recherche une maison et l’utilise pour créer de nouvelles
instances de composant
 Finder – Recherche instances de composant existantes via le service de
Nommage, de Courtage ou via les opérations de recherche des maisons
 Optionnellement démarcation des transactions
 begin, commit et rollback
 Peut établir les crédits de sécurité
 Invoque les opérations des instances de composant
 Celles définies par la projection vers OMG IDL
 Client ne sait pas nécessairement qui interagit avec des composants
© 2003, P. Merle
ICAR’03
42
L’utilisation de composants CORBA
via OMG IDLscript
# Obtenir le service de recherche de maisons de composants.
chf = CORBA.ORB.resolve_initial_references
(“ComponentHomeFinder”)
# Rechercher une maison selon son type.
forkHome = chf.find_home_by_type(ForkHome.id())
# Créer un composant fourchette.
forkManager = forkHome.create()
# Obtenir la facette fourchette.
fork = forkManager.provide_the_fork()
# Utiliser la facette fourchette.
fork.get()
. . . . . . .
fork.release()
© 2003, P. Merle
ICAR’03
43
L’interconnexion de composants
CORBA avec OMG IDLscript
# Obtenir les composants CORBA à interconnecter.
kant = Philosopher(“corbaname:…”)
observer = Observer(“corbaname:…”)
Philosopher
name = Kant
Observer
# Connecter les composants kant et observer.
ck = kant.subscribe_info(observer.get_consumer_info())
. . . . . .
# Déconnecter les composants kant et observer.
kant.unsubscribe_info(ck)
© 2003, P. Merle
ICAR’03
44
La navigation et l’introspection
des composants CORBA
 Navigation d’une facette vers le composant via opération
CORBA::Object::get_component()
 Retourne la référence de base du composant ou nil si pas une facette
 Navigation du composant vers les facettes et puits via les
opérations introduites lors de la projection vers OMG IDL
 Opérations génériques de navigation, de contrôle et
d’introspection fournies par l’interface CCMObject
 provide_facet, get_[all|named]_facets, same_component
 connect, disconnect, get_connections,
get_[all|named]_receptacles
 get_consumer, get_[all|named]_consumers
 subscribe, unsubscribe, [dis]connect_consumer,
get_[all|named]_[emitters|publishers]
 get_all_ports, get_ccm_home, get_component_def, get_ccm_home,
get_primary_key
 Au cœur de l’interconnexion des composants au déploiement et
de l’administration des composants à l’exécution
© 2003, P. Merle
ICAR’03
45
Le développement des
composants CORBA
© 2003, P. Merle
ICAR’03
46
Le développement des
composants CORBA
 Décrire la structure d’implantation des composants
 Via OMG Component Implementation Definition Language (CIDL)
 Compositions, segments et états persistants
 Compiler les descriptions OMG CIDL
 Génération du code conteneur + squelette exécuteur
 Implanter les composants et les maisons
 Héritage du code généré
 Règles de programmation à respecter
 Compiler le code utilisateur + le code généré
© 2003, P. Merle
ICAR’03
47
La compilation OMG CIDL
Concepteur
Composant
OMG IDL
3.0
Concepteur
Composition
include
import
Conteneur
Composant
Développeur
Composant
Code
Composant
OMG CIDL
Compilateur
OMG CIDL
hérité
délègue
Local
Server-side
OMG IDL
© 2003, P. Merle
Implanté
partiellement
Code utilisateur
Squelette
Composant
ICAR’03
Compilateur
Code généré
48
L’implantation Java
des composants
 Héritage des squelettes OMG CIDL générés
 1 classe par maison implantant
 Opérations métiers explicites du concepteur
 1 méthode de fabrique des implantations des segments
 1 méthode statique point d’entrée pour le déploiement
 1 classe par composant implantant
 Opérations métiers des facettes supportées
 1 opération de réception des événements pour chaque puit supporté
 Surcharge des opérations de l’interface SessionComponent ou
EntityComponent
 1 classe par segment implantant
 Opérations métiers des facettes supportées
 1 opération de réception des événements pour chaque puit supporté
 2 classes par événement
 Implantation concrète et fabrique
© 2003, P. Merle
ICAR’03
49
L’interface SessionComponent
module Components {
local interface EnterpriseComponent
{
void configuration_complete()
raises(InvalidConfiguration);
};
local interface SessionComponent : EnterpriseComponent
{
void set_session_context(in SessionContext ctx)
raises(CCMException);
void ccm_activate()
raises(CCMException);
void ccm_passivate()
raises(CCMException);
void ccm_remove()
raises(CCMException);
};};
© 2003, P. Merle
ICAR’03
50
La composition OMG CIDL
pour composant Observer
composition session ObserverComposition
{
home executor ObserverHomeBase
{
implements DiningPhilosophers::ObserverHome;
manages ObserverBase;
};
};
© 2003, P. Merle
ICAR’03
51
La structure d’implantation
du composant Observer
ObserverComposition
ObserverHomeBase
ObserverHomeImpl
© 2003, P. Merle
ObserverBase
instancie
ICAR’03
ObserverImpl
52
L’implantation Java
de la maison ObserverHome
public class ObserverHomeImpl
extends ObserverComposition.ObserverHomeBase
{
// Le constructeur.
public ObserverHomeImpl() {}
// La fabrique des implantations de segments.
public org.omg.Components.ExecutorSegmentBase
create_executor_segment(int segid)
{ return new ObserverImpl(); }
// Le point d’entrée pour le déploiement.
public static org.omg.Components.HomeExecutorBase
create_home()
{ return new ObserverHomeImpl(); }
}
© 2003, P. Merle
ICAR’03
53
Le composant Observer
Observer
Observer
CCM_Observer_Executor
SessionComponent
CCM_StatusInfoConsumer
StatusInfoConsumer
ObserverBase
ObserverImpl
CCM_Observer_Context
SessionContext
© 2003, P. Merle
ICAR’03
54
L’implantation Java
du composant Observer (1/2)
public class ObserverImpl
extends ObserverComposition.ObserverBase
{
// Attributs internes pour IHM.
Observer
// Le constructeur.
public ObserverImpl() { ... }
// Pour interface CCM_StatusInfo_Consumer.
public void
push(StatusInfo event)
{
... Mise à jour IHM ...
}
../..
© 2003, P. Merle
ICAR’03
55
L’implantation Java
du composant Observer (2/2)
Observer
// Surcharge des opérations SessionComponent.
public void ccm_activate()
throws org.omg.Components.CCMException
{ ... Afficher IHM ... }
public void ccm_passivate()
throws org.omg.Components.CCMException
{ ... Cacher IHM ... }
public void ccm_remove ()
throws org.omg.Components.CCMException
{ ... Libérer les ressources IHM ... }
}
© 2003, P. Merle
ICAR’03
56
La composition OMG CIDL
pour composant Philosopher
composition session PhilosopherComposition
{
home executor PhilosopherHomeBase
{
implements DiningPhilosophers::PhilosopherHome;
manages PhilosopherBase;
};
};
© 2003, P. Merle
ICAR’03
57
La structure d’implantation
du composant Philosopher
PhilosopherComposition
PhilosopherHomeBase
PhilosopherHomeImpl
© 2003, P. Merle
PhilosopherBase
instancie
ICAR’03
PhilosopherImpl
58
L’implantation Java
de la maison PhilosopherHome
public class PhilosopherHomeImpl
extends PhilosopherComposition.PhilosopherHomeBase
{ // Le constructeur.
public PhilosopherHomeImpl() {}
// Pour CCM_PhilosopherHome
public org.omg.Components.EnterpriseComponent
_new(String name)
{ return new PhilosopherImpl(name); }
// Fabrique des implantations de segments.
public org.omg.Components.ExecutorSegmentBase
create_executor_segment(int segid)
{ return new PhilosopherImpl(null); }
// Le point d'entrée pour le déploiement.
public static org.omg.Components.HomeExecutorBase
create_home()
{ return new PhilosopherHomeImpl(); }
}
© 2003, P. Merle
ICAR’03
59
Le composant Philosopher
Philosopher
Philosopher
name = XXX
CCM_Philosopher_Executor
SessionComponent
PhilosopherBaseCCM_Philosopher_Context
PhilosopherImpl
SessionContext
© 2003, P. Merle
ICAR’03
60
Les interfaces de l’exécuteur
Philosopher
Philosopher
local interface CCM_Philosopher_Executor :
::Components::EnterpriseComponent name = XXX
{
attribute string name;
};
local interface CCM_Philosopher_Context :
::Components::CCMContext
{
// Obtenir la fourchette gauche actuellement connectée.
Fork get_connection_left();
// Obtenir la fourchette droite actuellement connectée.
Fork get_connection_right();
// Envoyer un événement à tous les puits connectés.
void push_info(in StatusInfo ev);
};
© 2003, P. Merle
ICAR’03
61
L’implantation Java
du composant Philosopher (1/4)
Philosopher
public class PhilosopherImpl
name = XXX
extends PhilosopherComposition.PhilosopherBase
implements java.lang.Runnable
{
// Attribut pour stocker le nom du philosophe.
private String name_;
// Le constructeur.
public PhilosopherImpl(String name) {name_=name;}
// Pour interface CCM_Philosopher_Executor.
public String name() { return name_; }
public void name(String n) { name_ = n; }
../..
© 2003, P. Merle
ICAR’03
62
L’implantation Java
du composant Philosopher (2/4)
Philosopher
name = XXX
// Surcharge des opérations EnterpriseComponent.
public void configuration_complete()
throws org.omg.Components.InvalidConfiguration
{
// Vérifier si la configuration est correcte.
if( (name_ == null)
|| (get_context().get_connection_left()==null)
|| (get_context().get_connection_right()==null))
{
throw new
org.omg.Components.InvalidConfiguration();
} }
© 2003, P. Merle
ICAR’03
63
L’implantation Java
du composant Philosopher (3/4)
Philosopher
// Surcharge des opérations SessionComponent.
name = XXX
// L'activité associée au philosophe.
private java.lang.Thread comportement_;
public void ccm_activate()
throws org.omg.Components.CCMException
{
comportement_ = new Thread(this);
comportement_.start();
}
public void ccm_remove()
throws org.omg.Components.CCMException
{ comportement_.stop(); }
© 2003, P. Merle
ICAR’03
64
L’implantation Java
du composant Philosopher (4/4)
Philosopher
// Le comportement du philosophe.
public void run()
name = XXX
{
...
// Envoyer son état aux observateurs.
get_context().push_info(new StatusInfoImpl(...));
...
// Prendre les fourchettes.
get_context().get_connection_left().get();
get_context().get_connection_right().get();
...
// Rendre les fourchettes.
get_context().get_connection_left().release();
get_context().get_connection_right().release();
...
} }
© 2003, P. Merle
ICAR’03
65
La composition OMG CIDL
pour composant ForkManager
composition session ForkComposition
{
home executor ForkManagerHomeBase
{
implements DiningPhilosophers::ForkHome;
manages ForkManagerBase
{
segment ForkSeg
{
provides facet the_fork;
}
};
};
};
© 2003, P. Merle
ICAR’03
66
La structure d’implantation
du composant Philosopher
<<CORBAInterface>>
Fork
ForkComposition
ForkManagerHomeBase
ForkManagerBase
ForkSeg
ForkHomeImpl
ForkManagerImpl
ForkSegImpl
© 2003, P. Merle
ICAR’03
67
L’implantation Java
de la maison ForkHome
public class ForkHomeImpl
extends ForkComposition.ForkManagerHomeBase
{ // La fabrique d'implantation des segments.
public org.omg.Components.ExecutorSegmentBase
create_executor_segment(int segid)
{
switch (segid) {
case 0:
return new ForkManagerImpl();
case ForkSegImpl._segment_id_value:
return new ForkSegImpl();
} }
// Le point d'entrée pour le déploiement.
public static org.omg.Components.HomeExecutorBase
create_home()
{ return new ForkHomeImpl(); }
}
© 2003, P. Merle
ICAR’03
68
Le composant ForkManager
Fork
Manager
ForkManager
CCM_ForkManager_Executor
SessionComponent
ForkManagerImpl
Fork
CCM_ForkManager_Context
CCM_Fork
ForkSegImpl
SessionContext
© 2003, P. Merle
ICAR’03
69
L’implantation Java
du composant ForkManager (1/2)
Fork
Manager
public class ForkManagerImpl
extends ForkComposition.ForkManagerBase
{
// Le constructeur.
public ForkManagerImpl() {}
// Surcharge des opérations SessionComponent.
// e.g. ccm_activate, ccm_passivate, ccm_remove.
}
© 2003, P. Merle
ICAR’03
70
L’implantation Java
du composant ForkManager (2/2)
public class ForkSegImpl
extends ForkComposition.ForkSeg
{
private boolean disponible_ = true;
Fork
Manager
// Prendre la fourchette.
public void get() throws InUse
{
if(!disponible_) throw new InUse();
disponible_ = false;
}
// Rendre la fourchette.
public void release()
{ disponible_ = true; }
}
© 2003, P. Merle
ICAR’03
71
L’implantation Java
de l’événement StatusInfo (1/2)
public class StatusInfoImpl
extends StatusInfo
{
public StatusInfoImpl(PhilosopherState s,
String n, int ticks,
boolean left_fork,
boolean right_fork)
{
state = s; name = n;
ticks_since_last_meal = ticks;
has_left_fork = left_fork;
has_right_fork = right_fork;
}
public StatusInfoImpl()
{ this(PhilosopherState.DEAD, "", 0, false, false); }
}
© 2003, P. Merle
ICAR’03
72
L’implantation Java
de l’événement StatusInfo (2/2)
public class StatusInfoFactory
implements org.omg.CORBA.portable.ValueFactory
{
// Lecture depuis un flux CORBA.
public java.io.Serializable
read_value(org.omg.CORBA_2_3.portable.InputStream in)
{
java.io.Serializable v = new StatusInfoImpl();
return in.read_value(v);
}
}
© 2003, P. Merle
ICAR’03
73
Le conditionnement et l’assemblage
des composants CORBA
© 2003, P. Merle
ICAR’03
74
Le conditionnement et l’assemblage
des composants CORBA
 Construire des archives ZIP
 De composants contenant




XML Component Software Descriptor (.csd)
XML CORBA Component Descriptors (.ccd)
XML Component Property Files (.cpf)
Fichiers OMG IDL + code binaires
 D’assemblage contenant
 XML Component Assembly Descriptor (.cad)
 Archives de composants
 XML Component Property Files (.cpf)
 Besoin d’outils de conditionnement et d’assemblage pour CCM
 Diverses approches et outils existent
 Combinaison de différents outils possible
© 2003, P. Merle
ICAR’03
75
Des outils de conditionnement et
d’assemblage des composants CORBA
Conditionneur / Assembleur
Composant
Atelier UML
Outil IHM
Rose, Poseidon, Objecteering
MicoCCM, K2, OpenCCM
N’importe quel
éditeur de texte
CCM XML + ZIP
Plate-forme CCM
© 2003, P. Merle
ICAR’03
76
Software Package Descriptor
pour Composant Observer
<?xml version="1.0"?>
<!DOCTYPE softpkg SYSTEM "softpkg.dtd">
<softpkg name="Observer" version="1,0,0,0">
<pkgtype>CORBA Component</pkgtype>
<title>Observer</title>
<author>
<name>Philippe Merle</name>
<company>INRIA</company>
<webpage href="http://www.inria.fr"/>
</author>
<description>The CCM dining philosophers example</description>
© 2003, P. Merle
ICAR’03
77
Software Package Descriptor
pour Composant Observer
<license href= "http://www.objectweb.org/license.html"/>
<idl id="IDL:DiningPhilosophers/Observer:1.0">
<link href="http://www.objectweb.org/philo.idl"/>
</idl>
<descriptor type="CORBA Component">
<fileinarchive name="observer.ccd"/>
</descriptor>
<propertyfile>
<fileinarchive name="observer.cpf"/>
</propertyfile>
<implementation> . . . </implementation>
</softpkg>
© 2003, P. Merle
ICAR’03
78
Software Package Descriptor
pour Composant Observer
<implementation id="Observer_impl">
<os name="WinNT" version="4,0,0,0"/>
<os name="Linux" version="2,2,17,0"/>
<processor name="x86"/>
<compiler name="JDK"/>
<programminglanguage name="Java"/>
<code type="Java class">
<fileinarchive name="ObserverHomeImpl.class"/>
<entrypoint>ObserverHomeImpl.create_home</entrypoint>
</code>
<runtime name="Java VM" version="1,2,2,0"/>
<runtime name="Java VM" version="1,3,0,0"/>
<dependency>...</dependency>
</implementation>
© 2003, P. Merle
ICAR’03
79
Software Package Descriptor
pour Composant Observer
<dependency type="ORB" action="assert">
<name>OpenORB</name>
</dependency>
<dependency type="Java Class" action="install">
<valuetypefactory
repid="IDL:DiningPhilosophers/StatusInfo:1.0"
valueentrypoint="DiningPhilosophers.StatusInfoDefaultFactory.create"
factoryentrypoint="DiningPhilosophers.StatusInfoDefaultFactory">
<fileinarchive
name="DiningPhilosophers/StatusInfoDefaultFactory.class"/>
</valuetypefactory>
</dependency>
© 2003, P. Merle
ICAR’03
80
CORBA Component Descriptor
pour Composant Philosopher
<?xml version="1.0"?>
<!DOCTYPE corbacomponent SYSTEM "corbacomponent.dtd">
<corbacomponent>
<corbaversion>3.0</corbaversion>
<componentrepid repid=
"IDL:DiningPhilosophers/Philosopher:1.0"/>
<homerepid repid=
"IDL:DiningPhilosophers/PhilosopherHome:1.0"/>
<componentkind>
<process><servant lifetime="container" /></process>
</componentkind>
<security rightsfamily="CORBA“
rightscombinator="secanyrights" />
<threading policy="multithread" />
<configurationcomplete set="true" />
© 2003, P. Merle
ICAR’03
81
CORBA Component Descriptor
pour Composant Philosopher
<homefeatures name="PhilosopherHome"
repid="IDL:DiningPhilosophers/PhilosopherHome:1.0"/>
<componentfeatures name="Philosopher"
repid="IDL:DiningPhilosophers/Philosopher:1.0">
<ports>
<uses usesname="right"
repid="IDL:DiningPhilosophers/Fork:1.0" />
<uses usesname="left"
repid="IDL:DiningPhilosophers/Fork:1.0" />
<publishes emitsname="info"
eventtype="StatusInfo">
<eventpolicy policy="normal" />
</publishes>
</ports>
</componentfeatures>
<interface name="Fork" repid="IDL:DiningPhilosophers/Fork:1.0"/>
© 2003, P. Merle
ICAR’03
82
Property File pour Philosopher Kant
<?xml version="1.0"?>
<!DOCTYPE properties SYSTEM "properties.dtd">
<properties>
<simple name="name" type="string">
<description>Philosopher name</description>
<value>Kant</value>
<defaultvalue>Unknown</defaultvalue>
</simple>
</properties>
© 2003, P. Merle
ICAR’03
83
L’assemblage des composants
du dîner des philosophes
Composant
Philosopher
Interf. base
Facette
Fork
Réceptacle
name = Kant
Puit évén.
Fork
Source évén.
Philosopher
Fork
name = Descartes
Philosopher
name = Aristotle
© 2003, P. Merle
Observer
ICAR’03
84
Component Assembly Descriptor
pour dîner des philosophes
<?xml version="1.0"?>
<!DOCTYPE componentassembly SYSTEM "componentassembly.dtd">
<componentassembly id="demophilo">
<description>Dinner assembly descriptor</description>
<componentfiles>
<componentfile id="PhilosopherComponent">
<fileinarchive name="philosopher.csd"/>
</componentfile>
<componentfile id="ObserverComponent">
<fileinarchive name="observer.csd"/>
</componentfile>
<componentfile id="ForkManagerComponent">
<fileinarchive name="forkmanager.csd"/>
</componentfile>
</componentfiles>
© 2003, P. Merle
ICAR’03
85
Component Assembly Descriptor
pour dîner des philosophes
<partitioning>
<homeplacement id="ObserverHome">
<componentfileref idref="ObserverComponent"/>
<componentinstantiation id="Freud"/>
<registerwithnaming name="Dinner/ObserverComponent"/>
</homeplacement>
<homeplacement id="ForkHome">
<componentfileref idref="ForkManagerComponent"/>
<componentinstantiation id="ForkManager1"/>
<componentinstantiation id="ForkManager2"/>
<componentinstantiation id="ForkManager3"/>
<registerwithhomefinder name="ForkHome"/>
</homeplacement>
© 2003, P. Merle
ICAR’03
86
Component Assembly Descriptor
pour dîner des philosophes
<homeplacement id="PhilosopherHome">
<componentfileref idref="PhilosopherComponent"/>
<componentinstantiation id="Kant">
<componentproperties><fileinarchive name="Kant.cpf"/>
</componentproperties></componentinstantiation>
<componentinstantiation id="Descartes">
<componentproperties><fileinarchive name="Descartes.cpf"/>
</componentproperties></componentinstantiation>
<componentinstantiation id="Aristotle">
<componentproperties><fileinarchive name="Aristotle.cpf"/>
</componentproperties></componentinstantiation>
</homeplacement>
</partitioning>
© 2003, P. Merle
ICAR’03
87
Component Assembly Descriptor
pour dîner des philosophes
<connections>
Philosopher
<connectinterface>
Fork
name = Kant
<usesport>
<usesidentifier>left</usesidentifier>
<componentinstantiationref idref="Kant"/>
</usesport>
<providesport>
<providesidentifier>the_fork</providesidentifier>
<componentinstantiationref idref="ForkManager1"/>
</providesport>
</connectinterface>
© 2003, P. Merle
ICAR’03
88
Component Assembly Descriptor
pour dîner des philosophes
Philosopher
<connectevent>
name = Kant
Observer
<publishesport>
<publishesidentifier>info</publishesidentifier>
<componentinstantiationref idref="Kant"/>
</publishesport>
<consumesport>
<consumesidentifier>info</consumesidentifier>
<componentinstantiationref idref="Freud"/>
</consumesport>
</connectevent>
© 2003, P. Merle
ICAR’03
89
L’outil de conditionnement et
d’assemblage d’OpenCCM
© 2003, P. Merle
ICAR’03
90
L’outil d’assemblage de MicoCCM
© 2003, P. Merle
ICAR’03
91
L’outil d’assemblage de K2
© 2003, P. Merle
ICAR’03
92
Le plug-in Rational Rose
du projet IST COACH
CCM
CORBA Component
© 2003, P. Merle
ICAR’03
93
Le plug-in Rational Rose
du projet IST COACH
<<CORBAAssembly>>
Philosophers_3
philosopher_home :
PhilosopherHome
i1 : Fork
p1 :
Philosopher
r1: right
i6 : Fork
l1 : left
f1 : fork
philosopher_st ate : philosopher_state
f6 : fork
f1 :
Cut lery
philosopher_state1 :
PhilosopherState
f3 :
Cutlery
f2 : fork
philosopher_state : philosopher_st...
observerHome_plcmnt :
ObserverHome
i2 : Fork
i5 : Fork
o1 :
Observer
l2 : left
philosopher_state : philosopher_st...
r3 : right
philosopher_state : philosopher_st...
p2 :
Philosopher
philosopher3 :
Philosopher
philosopher_state : philosopher_st...
r2 : right
philosopher_state2 :
PhilosopherState
i3 : Fork
f5 : fork
f3 : fork
philosopher_state : philosopher_st...
l3 : left
philosopher_s tat e3 :
PhilosopherStat e
f2 :
Cutlery
f4 : fork
i4 : Fork
cutlery_home :
CutleryHome
© 2003, P. Merle
ICAR’03
94
Le plug-in Rational Rose
du projet IST COACH
© 2003, P. Merle
ICAR’03
95
Le plug-in Rational Rose
du projet IST COACH
PLATIN
Fraunhofer
Fokus
CORBA
Component
http://www.fokus.fraunhofer.de
http://www.fokus.fraunhofer.de
Philosopher_S
Philosopher_W
© 2003, P. Merle
The Dining Philosopher Example
ICAR’03
Philosopher_W
96
Le déploiement, l’exécution et
l’administration de l’application
© 2003, P. Merle
ICAR’03
97
Le déploiement, l’exécution et
l’administration de l’application
 Déploiement automatisé
 Lancement via un outil de déploiement
 Exécution automatisée
 Lancement de démons à faire manuellement
 1 domaine


1 CORBA Naming Service
1 CCM Assembly Factory
 1 machine


1 CCM Server Activator
1 CCM Component Installation
Déployer
le dîner des
philosophes
avec
OpenCCM
 Administration de l’application
 Des programmes clients ad hoc à l’application
 Utilisation d’une console générique
© 2003, P. Merle
ICAR’03
98
La console d’administration
OpenCCM
© 2003, P. Merle
ICAR’03
99
Conclusion
© 2003, P. Merle
ICAR’03
100
Conclusion
 Pas si compliqué si correctement expliqué (?)
 Pas parfait mais puissant
 Bonne source d’inspiration pour faire mieux ;-)
© 2003, P. Merle
ICAR’03
101
Merci
© 2003, P. Merle
ICAR’03
102