m1 presentation osgi

30
MIAGE M1 St-Marcel - @VELOSSITY Christophe Saint- Marcel MIAGE M1 OSGi TM Un système dynamique de services Java devenue un framework à composants

Upload: velossity

Post on 22-May-2015

853 views

Category:

Education


1 download

DESCRIPTION

Cours d'introduction au framework OSGi - Miage M1 Université de Grenoble

TRANSCRIPT

Page 1: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Christophe Saint-Marcel

MIAGE M1

OSGiTM

Un système dynamique de services Java

devenue un framework à composants

Page 2: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Définitions

OSGi™ - The Dynamic Module System for Java™

 …new service-oriented programming model, referred to by some as “SOA in a VM.” OSGI in Action ©Manning Publications Co

Enfin, la réutilisation de logiciel à portée de la main! C. Saint-Marcel

Page 3: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Caractéristiques principales

Modularisation des applications Chargement/Déchargement de code dynamique

pour le langage Java Déploiement dynamique d’applications sans

interruption de la plateforme Installation, Lancement, Mise à jour, Arrêt, Retrait No « reboot » Résolution des dépendances versionnées de code

Page 4: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Domaines d’applications

Initialement, Systèmes embarqués– Véhicule de transport (automotive)– Passerelle résidentiel/domotique/immotique– Contrôle industriel– Téléphonie mobile

Serveurs d’application– JOnAS 5, Geronimo, ApacheDS, JAMES, WebSphere,

JBoss 5 …

Eclipse !

Page 5: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Schneider et OSGiTM: Résidentiel

Page 6: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Schneider et OSGiTM: Building

Page 7: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Un marché pour le résidentiel

From Orange Open Home Automation Infrastructure - J.M. Ortholand, A. Bottaro, nov 2011

Page 8: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Démonstrateur

Cf. HOMES MULTISENSOR

http://www2.schneider-electric.com/sites/corporate/fr/presse/dossiers/projet-homes.page

Page 9: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Un peu d’histoire

Mars 1999 : Fondation de l’OSGi Alliance, un consortium d’industriels

Aujourd’hui, plus de 40 sociétés membres Au départ une plateforme embarquée pour les passerelles

résidentielles : Open Services Gateway initiative Plusieurs groupes d’experts:

– Core Platform Expert Group (CPEG) – Framework– Enterprise Expert Group (EEG) – Enterprise Issues– Residential Expert Group (EEG) – Home AutomationGroupes inactifs:– Mobile Expert Group (MEG) – Mobile Telephony– Vehicle Expert Group (VEG) - Automobile

Page 10: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

FrameworkHttpLogDevice Access

Un standard en construction

UPnPInitial ProvisioningName SpaceJiniStart LevelIO ConnectorWire AdminXML ParserMeasurement & StatePositionExecution Env.

Application ManagerForeign App. AccessSigned BundlesDeclarative ServicesDevice ManagementSecurity PoliciesFramework LayeringInitial ProvisioningUPnPConditional Permissions…

2000 2001 2003 2006

R1

R2

R3

R4

Ho

me

Au

tom

ati

on

Ve

hic

le

Mo

bil

e

Package AdminConfiguration AdminPermission AdminUser AdminPreferencesMetaTypeService Tracker

From Peter Kriens, aQute

R2

Page 11: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Sortie officielle en juin 2012

OSGi R5

CoreResource APIVersion range

Compendium & EnterpriseRepository ServiceResolver ServiceSubsystems ServiceService loader MediatorCommon Namespaces…

Page 12: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Fournisseurs de solutions

Equinox (OSGi-Framework – du projet Eclipse (Enterprise)

Apache Felix – projet de la communauté Apache

Knopflerfish – originellement commercialisé comme un produit embarqué de Gatespace

ProSyst – Solution commerciale

R4.3

Page 13: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Architecture d’une plateforme OSGiTM

Plateforme

Page 14: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

La couche Services offre la possibilité de mettre à disposition des services au sein d'une même machine virtuelle tout en masquant leurs implémentations à leurs utilisateurs.

La couche Cycle de vie prend en charge les états des bundles

La couche Module adresse la gestion du chargement des classes (classloading), la gestion de leurs visibilités et de leurs versions dans chaque bundle.

Architecture du framework

Module

Cycle de vie

Services

Framework

Page 15: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Comment ça marche : le bundle

L’unité de déploiement: le bundle est le bloc de légoTM

– Unité de livraison et de déploiement sous forme de jar

– Une application OSGiTM est un assemblage de bundles

– Chaque bundle est un isolat

Module

Page 16: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Structure d’un bundle

Module

Page 17: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Déploiement du bundle

Le Framework:– Lit le manifest du jar– Installe le code et les ressources– Résolve les dépendances– Contrôle le cycle de vie du bundle– Appelle le Bundle Activator pour démarrer le

bundle

Cycle de vie

Page 18: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Cycle de vie du bundle

Cycle de vie

Page 19: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Comment ça marche : µSOA

Architecture orienté service (µServices)

Le service est défini par un contrat (Service API)

Le fournisseur publie le service dans le registre

Le service a son propre cycle de vie, il peut venir et partir à tout moment

Le consommateur demande un fournisseur de service au registre, il peut aussi être notifié de l’apparition et de la disparition d’un fournisseur

Le consommateur s’associe au fournisseur, il invoque le service

Service registry

Service API

ServiceRequester

ServiceProvider

Requests

Invoke

Publishes

Component Java Interface

Notifies

Binds

Services

Page 20: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Mais où sont les composants?

Le service ? Le bundle ?

Le framework OSGiTM natif est un framework à composants primitifs ! Dynamique difficile à gérer Mélange du code métier et technique

Page 21: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Les modèles à composants sur OSGiTM

Plusieurs approches concurrentes Basées sur un modèle déclaratif, chaque

composant décrit ce qu’il fournit et ce qu’il requiert

Abstraction de la dynamicité pour se concentrer sur le métier

Un composant est déployé dans un bundle

Page 22: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Modélisation des composantscmp Big Picture

DatabaseField bus

Business API

REST Connector

DataStorage

MultiSensor.storage

Multis ensor

ZigbeeFactory

RESTAdapter

HDDe vice

Device

MultiSensorStorage

java.sql.Connection

Page 23: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Solutions concurrentes

Plusieurs approches toutes compatibles:– Le SCR spécifié en 1.4– Blueprint– iPOJO, le préféré des Grenoblois– Dependency Manager– FROGi (Fractal over OSGiTM)

Page 24: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Exemple de déclaration

Page 25: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

OSGiTM : une technologie mature

Modèle à composants déclaratif de haut niveau Nombreux bundles open-source

– http://wiki.chameleon.ow2.org/xwiki/bin/view/Main/WebHome

Outils de construction adaptés– Maven: construction de bundles

http://mvnrepository.com/– Nexus: entrepôts de bundles– Jenkins: intégration continue des bundles

http://velossity.zapto.org:8080/

Page 26: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

OSGiTM : un paradoxe?

Page 27: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

OSGiTM : un paradoxe?

DZone: How widespread is OSGi in the Java community and what are your predictions for how adoption will change based on the introduction of Jigsaw?

Kirk: Fascinating question. Just about every software developer is an OSGi consumer today because just about every platform and every IDE use OSGi. The major platform vendors, including IBM, Oracle, and Red Hat are all using OSGi to build up their platforms. What's interesting is that OSGi hasn't penetrated the enterprise developer space yet. At least, it hasn't gone mainstream yet. Some people might complain that OSGi is too complex. But what they're really saying is that designing modular software is really really hard. Because it is.

http://java.dzone.com/articles/osgi-vs-jigsaw-kirk

Page 28: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

OSGiTM : une solution ultime?

David Lloyd at https://community.jboss.org/thread/229889?_sscc=t

At this time, it has been decided to remove OSGi support from WildFly for various reasons.  OSGi support will continue within our SOA platform.  I personally do not view OSGi as a viable technology but on the other hand it is possible that the winds may shift and that we may revisit this decision some day.  Note that since we have a flexible low-level core in WildFly, the choice of specifications to support do not carry down into any kind of basic architectural lock-in so we're never really "too far" from supporting any given container specification or component model, so to me this isn't a terribly drastic choice, just a pragmatic one based on the current known factors

Page 29: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

OSGiTM : la concurrence

Jigsaw+ Java natif, modularisation du JRE intégrée à Java 8? – Pas encore sorti et éprouvé

Android (http://www.adon-line.de/kunden/prosystBlog/?p=18)+ Simplicité, modèle d’application

- Communication inter-process, Pas de versionnement

.Net (http://www.aqute.biz/presentations/WhyOSGI.ppt)+ Managed Extensibility Framework (MEF)

- Pas de standard / Single platform

Page 30: M1 presentation OSGi

MIAGE M1 St-Marcel - @VELOSSITY

Bibliographie

http://france.osgiusers.org/Main/HomePage Peter Kriens –

http://www.aqute.biz/Main/HomePage Didier Donsez - http://membres-

liglab.imag.fr/donsez/cours/exemplesosgi/

Cette présentation est à retrouver à l’adressehttp://fr.slideshare.net/saintmar/m1-presentation-os-gi