Component-based ontwikkelen met OSGi: van embedded tot enterprise

Post on 10-Jun-2015

60 views 0 download

description

After a short introduction about the origins of OSGi and the principles behind it, this presentation will focus on the current developments around component-based development. Although OSGi was created as a service-based platform for home gateways, it has grown into a universally applicable framework. The talk will review JSR-277 and JSR-291, both of which are very close to OSGi and are targetted to standardize certain aspects of this technology as part of the JVM. Furthermore, several applications will be reviewed to illustrate that this architecture can be used in a broad range of environments, from mobile phones to enterprise applications. Examples include: Eclipse, based on OSGi since 3.0, Apache Felix, an open source implementation that is the basis for several other projects such as the Apache Directory Server.

Transcript of Component-based ontwikkelen met OSGi: van embedded tot enterprise

1

Component-based ontwikkelen met OSGivan embedded tot enterprise

Marcel Offermans

2

Even voorstellenMarcel Offermans– Software architect bij

luminis®– Committer bij

Apache Felix

e-mail: marcel.offermans@luminis.nl

3

Agenda• OSGi

– Geschiedenis– Het framework in vogelvlucht

• Standaardisatie efforts rond OSGi– JSR 277 en JSR 294– JSR 291

• Van embedded naar enterprise– Apache Harmony– Apache Directory Server– Cocoon, Spring, Eclipse, James

4

Agenda• OSGi

– Geschiedenis– Het framework in vogelvlucht

• Standaardisatie efforts rond OSGi– JSR 277 en JSR 294– JSR 291

• Van embedded naar enterprise– Apache Harmony– Apache Directory Server– Cocoon, Spring, Eclipse, James

5

OSGi geschiedenis• Ontstaan als standaard embedded platform voor

de “home gateway”• Aanvankelijk onder JCP als JSR-8 (1999)• OSGi alliance, bestaande uit een groot aantal

vooraanstaande bedrijven, met als missie:– Beheren en publiceren de OSGi specificatie.– Certificeren van implementaties.– Organiseren van events.

• Huidige versie: OSGi Release 4 (augustus 2005)

6

OSGi Framework• Component gebaseerd framework• Componenten heten bundles• Framework:

• security layer• module layer• life-cycle layer• service registry

Security

Module

Life-cycle

Service

Bundle Bundle Bundle

7

OSGi Security layer• Gebaseerd op Java 2 security model• Mogelijkheid om bundles te signen• Permission Admin service verzorgt dynamische

configuratie

Security

Module

Life-cycle

Service

Bundle Bundle Bundle

8

OSGi Module layer• Eenheid van modularisatie is de bundle (JAR)• Bundle bevat Java packages (en resources)• Bundle bepaalt welke packages publiek

toegankelijk zijn (geexporteerd worden) en welke niet: naam + versienummer

• Bundle geeft ook aan welke externe packages nodig zijn (imports): naam + versie range Security

Module

Life-cycle

Service

Bundle Bundle Bundle

9

OSGi Life-cycle layer• Beheert de life-cycle van bundles• BundleActivator start() en stop() hooks

Security

Module

Life-cycle

Service

Bundle Bundle Bundle

10

OSGi Service registry• Bundles kunnen services registreren:

• op naam: net.luminis.DataStore• aangevuld met properties: { type=file, atomic=no }

• Bundles kunnen servicesgebruiken:• via registratie van listener• met dependency injection• via declarative services

Security

Module

Life-cycle

Service

Bundle Bundle Bundle

11

OSGi frameworks & tools• Verschillende open source implementaties:

– Apache Felix– Eclipse Equinox– Gatespace Telematics' Knopflerfish

• Eclipse IDE project support– IDE/RCP is gebaseerd op OSGi– Bundles heten “plug-ins”

• Maven 2 support– Nog volop in ontwikkeling, maar bruikbaar

12

Agenda• OSGi

– Geschiedenis– Het framework in vogelvlucht

• Standaardisatie efforts rond OSGi– JSR 277 en JSR 294– JSR 291

• Van embedded naar enterprise– Apache Harmony– Apache Directory Server– Cocoon, Spring, Eclipse, James

13

JSR-277 Java Module System• Versioning

– Hoe nummer je versies?– Hoe draai je meerdere versies parallel?

• Distributie en packaging– JAR files?

• Dynamische connectiviteit– Hoe resolve je modules?

• Repositories– Lokale opslag– Beheer en security

14

JSR-277 Java Module System (2)• Pluspunten

– Goed om dit in standaard Java te regelen

• Minpunten– Richt zich aanvankelijk alleen op J2SE– Onderdeel van Java 7 (pas in 2008)

15

JSR-294 Improved Modularity Support• Richt zich op development (JSR-277 op

deployment)• Information Hiding

– Introductie van “superpackages” die beschrijven wat publiek is en wat private.

• Module files– Meerdere versies kunnen tegelijk aanwezig zijn

• Afzonderlijk compileren– Simpel gezegd, compileren met alleen de publieke

interfaces beschikbaar

JSR-294 Improved Modularity Support (2)

super package com.sun.myModule {export com.sun.myModule.myStuff.*;export com.sun.myModule.yourStuff.Interface;

com.sun.myModule.myStuff;com.sun.myModule.yourStuff;com.sun.SomeOtherModule.theirStuff;org.someOpenSource.someCoolStuff;

}

16

17

JSR-294 Improved Modularity Support (3)• Pluspunten

– Wederom, dit is goed om te standaardiseren

• Minpunten– Ten tijde van de JavaOne 2006 nog veel

onbeantwoorde vragen

18

JSR-291 Dynamic Component Support• Richt zich op alle Java SE versies (oud en nieuw)• Complementair met JSR-232, die 't zelfde doet

voor Java ME (CDC profiel)• Dynamic Component Model• Life-cycle Management• Bouwt op de ervaringen van Apache, Eclipse en

OSGi• Subset van OSGi R4 (geen service registry)

19

JSR-291 Dynamic Component Support (2)• Pluspunten

– Bouwt voort op ervaring– Voor alle Java versies

• Minpunten– Risico op politieke weerstand van Sun

20

Agenda• OSGi

– Geschiedenis– Het framework in vogelvlucht

• Standaardisatie efforts rond OSGi– JSR 277 en JSR 294– JSR 291

• Van embedded naar enterprise– Apache Harmony– Apache Directory Server– Cocoon, Spring, Eclipse, James

21

Apache Harmony• Doelstellingen:

– Implementatie van Java 5 SE– Modulaire architectuur (VM en class libraries)– Beschermen van “intellectual property”

• Project is een jaar oud• Donaties van onder andere Intel en IBM

22

Apache Harmony (2)Architectuur in vogelvlucht:

23

Apache Harmony (3)Modulaire Java API implementatie:

Donatie van Intelbekendgemaakt op JavaOne

24

Apache Directory Server• Server software met OSGi als basis, omdat:

– Het tijdens ontwikkeling zorgt voor:• scheiding van verantwoordelijkheden.

– Het run-time ervoor zorgt dat:• de server niet gestopt hoeft te worden voor updates;• third-party vendors eenvoudig nieuwe functionaliteit

kunnen toevoegen;

25

Spring Framework• Support voor OSGi in de roadmap voor 2.1 RC1

(issue SPR-1802):– Spring zelf deployen als een set bundles.– Spring application context in een bundle.– Integratie van OSGi services en Spring's

dependency injection, met proxy support.

• Natuurlijke aanvulling op Spring, het brengt meer dynamica.

26

Cocoon• Een jaar geleden

begonnen met experimenteren met OSGi

27

Eclipse• Plug-in = bundle• Basis van Eclipse en

RCP is Equinox, een OSGi R4 implementatie

• Uitgebreide support voor:– ontwikkelen van bundles– uitvoeren en debuggen– hot code replace

28

Eclipse

Apache James Enterprise Mail Server!From: apache@bago.org!Subject: Re: ApacheCon EU OSGi panel!Date: June 14, 2006 18:53:14 GMT+02:00!To: !felix-dev@incubator.apache.org!Cc: server-dev@james.apache.org!I just want to add that also we, at Apache James project, discussed about removing our Avalon Phoenix dependency in favor of OSGi/Felix.

I crosspost this to james server-dev list, to let James developers know of this message and eventually raise questions, and felix may be interested to know that also James like Directory, Harmony and Cocoon is monitoring Felix.

29

Conclusies• Waar OSGi jaren geleden primair voor de

embedded “home gateway” ontworpen is, zie je dat de problemen die het oplost ook voor desktop en server applicaties relevant zijn.

• Er zijn een aantal standaarden in ontwikkeling om delen van de door OSGi geboden functionaliteit vast te leggen in het Java Community Proces, met momenteel nog redelijk wat overlap tussen verschillende standaards.

30

31

Vragen?

http://www.luminis.nl/

marcel.offermans@luminis.nl

Meer weten? Links... • OSGi sites

– http://osgi.org/ en http://bundles.osgi.org/

– http://incubator.apache.org/felix/

– http://www.knopflerfish.org/

– http://www.eclipse.org/osgi/

• BoekenEr zijn niet veel boeken over OSGi, dus ik raad een ieder aan om in elk geval op internet te zoeken naar informatie en de OSGi specificatie te lezen.

– Eclipse Rich Client Platform : Designing, Coding, and Packaging Java(TM) ApplicationsGoed boek waar ook een hoop instaat over OSGi ontwikkeling in het algemeen.

– Programming Open Service Gateways with Java Embedded Server™ TechnologyEen oud boek, dus qua specificatie wel gedateerd, maar wel geschikt om de basisprincipes te leren.

32