60
Warum OSGi Christian Baranowski

Warum OSGi?

Embed Size (px)

DESCRIPTION

Slides form the Java Forum Stuttgart "Warum OSGi?". More Details see http://www.java-forum-stuttgart.de/abstracts.html#D7

Citation preview

Page 1: Warum OSGi?

Warum OSGiChristian Baranowski

Page 2: Warum OSGi?

Willkommen• Christian Baranowski

• Software Qualitätssicherung @ SEITENBAU Gmbh Konstanz (DE)

• Custom Software Solutions

• E-Government Solutions

• Identity Management and SSO Solutions

• www.seitenbau.de

• Vorstand OSGi Users' Forum Germany

• Co-lead (mit Jochen Hiller) German Enterprise Working Group.

• OSGi Code Camp

Page 3: Warum OSGi?

OSGi

Page 4: Warum OSGi?

OSGi

ModularityModules

Page 5: Warum OSGi?

OSGi

ModularityModules Lifecycle

Page 6: Warum OSGi?

OSGi

ModularityModules Lifecycle Services

B

A

Service

Page 7: Warum OSGi?

OSGi

ModularityModules Lifecycle Services

Security

B

A

Service

Page 8: Warum OSGi?

OSGi

ModularityModules Lifecycle Services

Security

B

A

Serviceist����������� ������������������  ein����������� ������������������  offener����������� ������������������  Standard����������� ������������������  der����������� ������������������  

Page 9: Warum OSGi?

Warum OSGi?

Page 10: Warum OSGi?

Erweiterbarkeit / Plugins

Page 11: Warum OSGi?

Erweiterbarkeit / Plugins

Firefox Eclipse Maven

JenkinsSpring Roo

Page 12: Warum OSGi?

Bundle

JAR

Page 13: Warum OSGi?

Bundle

JAR

Private����������� ������������������  Packages

Page 14: Warum OSGi?

Bundle

JAR

Private����������� ������������������  Packages

Exported����������� ������������������  Packages

Page 15: Warum OSGi?

Bundle

JAR

Private����������� ������������������  Packages

Exported����������� ������������������  Packages

Imported����������� ������������������  Packages

Page 16: Warum OSGi?

Funktionen Klassen Packages

Modul Level

Page 17: Warum OSGi?

Funktionen Klassen Packages Bundles

Modul Level

Page 18: Warum OSGi?

Bundles

Page 19: Warum OSGi?

BundlesA

Provider����������� ������������������  Bundle

Page 20: Warum OSGi?

BundlesA

Provider����������� ������������������  Bundle

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: ABundle-Version: 1.0.1Export-Package: echo.api;version="1.0.0", echo.sysout;version="1.0.0"

Page 21: Warum OSGi?

BundlesA B

Consumer����������� ������������������  BundleProvider����������� ������������������  Bundle

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: ABundle-Version: 1.0.1Export-Package: echo.api;version="1.0.0", echo.sysout;version="1.0.0"

Page 22: Warum OSGi?

BundlesA B

Consumer����������� ������������������  BundleProvider����������� ������������������  Bundle

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: BBundle-Version: 1.0.0Import-Package: echo.api;version="[1.0,2)", echo.sysout;version="[1.0,2)"

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: ABundle-Version: 1.0.1Export-Package: echo.api;version="1.0.0", echo.sysout;version="1.0.0"

Page 23: Warum OSGi?

Demo Modularity / Lifecycle

API

World

Box

Provisioning

Extender

Arch

Desktop

Page 24: Warum OSGi?

OSGi Services

Page 25: Warum OSGi?

OSGi Services

API����������� ������������������  Bundle

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: apiBundle-Version: 2.0.0Export-Package: echo.api;version="1.0.0"

Page 26: Warum OSGi?

OSGi ServicesProvider����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: apiBundle-Version: 2.0.0Export-Package: echo.api;version="1.0.0"

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: ABundle-Version: 1.0.1Import-Package: echo.api;version="[1.0,2)"Service-Component: OSGI-INF/EchoProvider.xml

Page 27: Warum OSGi?

OSGi ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: apiBundle-Version: 2.0.0Export-Package: echo.api;version="1.0.0"

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: BBundle-Version: 1.0.0Import-Package: echo.api;version="[1.0,2)"Service-Component: OSGI-INF/EchoClient.xml

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: ABundle-Version: 1.0.1Import-Package: echo.api;version="[1.0,2)"Service-Component: OSGI-INF/EchoProvider.xml

Page 28: Warum OSGi?

OSGi ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: apiBundle-Version: 2.0.0Export-Package: echo.api;version="1.0.0"

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: BBundle-Version: 1.0.0Import-Package: echo.api;version="[1.0,2)"Service-Component: OSGI-INF/EchoClient.xml

Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-SymbolicName: ABundle-Version: 1.0.1Import-Package: echo.api;version="[1.0,2)"Service-Component: OSGI-INF/EchoProvider.xml

Instance����������� ������������������  Coupling

Page 29: Warum OSGi?

Service Registry

Provider

Consumer

Service Registry

- register- unregister

- get- listen

Name Valuetype api.Echo

availavility 5

Name Valuetype api.Echo

availavility 5... ...

Page 30: Warum OSGi?

OSGi Services Demo

API

World

Robot Sensordevices

Desktop

Wall

Page 31: Warum OSGi?

OSGi Declarative Services

API����������� ������������������  Bundle

Page 32: Warum OSGi?

OSGi Declarative Services Provider����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

<scr:component name="echo.sysout.EchoProvider"> <implementation class="echo.sysout.EchoProvider"/> <service> <provide interface="echo.api.Echo" /> </service></scr:component>

Page 33: Warum OSGi?

OSGi Declarative Services Consumer����������� ������������������  BundleProvider����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

<scr:component name="echo.consumer.EchoClient"> <implementation class="echo.consumer.EchoClient"/> <reference name="Echo" interface="echo.api.Echo" bind="setEcho" unbind="unsetEcho" /></scr:component>

<scr:component name="echo.sysout.EchoProvider"> <implementation class="echo.sysout.EchoProvider"/> <service> <provide interface="echo.api.Echo" /> </service></scr:component>

Page 34: Warum OSGi?

DS AnnotationConsumer����������� ������������������  BundleProvider����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

import org.osgi...annotations.*;import echo.api.Echo;

@Componentpublic class EchoClient {

Echo echo; @Reference public void setEcho(Echo echo){ this.echo = echo; } public void unsetEcho(Echo echo){ this.echo = null; }}

import org.osgi.service.component.annotations.*;import echo.api.Echo;

@Componentpublic class EchoProvider implements Echo { @Activate public void activate() { }

}

Page 35: Warum OSGi?

Blueprint Services

API����������� ������������������  Bundle

Page 36: Warum OSGi?

Blueprint ServicesConsumer����������� ������������������  Bundle

API����������� ������������������  Bundle

<blueprint> <bean class="echo.consumer.EchoClient"> <property name="echo" ref="echo" /> </bean></blueprint>

core-context.xml

Page 37: Warum OSGi?

Blueprint ServicesConsumer����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

<blueprint> <bean class="echo.consumer.EchoClient"> <property name="echo" ref="echo" /> </bean></blueprint>

<blueprint>

<reference id="echo" interface="echo.api.Echo"/></blueprint>

core-context.xml

osgi-context.xml

Page 38: Warum OSGi?

Blueprint ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

<beans> <context:component-scan

base-package="echo.sysout" /></beans>

core-context.xml

@Component("echo")public class EchoProvider implements Echo { @PostConstruct public void init() { }}

Spring����������� ������������������  Proprietär

<blueprint> <bean class="echo.consumer.EchoClient"> <property name="echo" ref="echo" /> </bean></blueprint>

<blueprint>

<reference id="echo" interface="echo.api.Echo"/></blueprint>

core-context.xml

osgi-context.xml

Page 39: Warum OSGi?

Blueprint ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  Bundle

API����������� ������������������  Bundle

Service

<beans> <context:component-scan

base-package="echo.sysout" /></beans>

core-context.xml

<blueprint> <service ref="echo"

interface="echo.api.Echo" /></blueprint>

@Component("echo")public class EchoProvider implements Echo { @PostConstruct public void init() { }}

osgi-context.xml

Spring����������� ������������������  Proprietär

<blueprint> <bean class="echo.consumer.EchoClient"> <property name="echo" ref="echo" /> </bean></blueprint>

<blueprint>

<reference id="echo" interface="echo.api.Echo"/></blueprint>

core-context.xml

osgi-context.xml

Page 40: Warum OSGi?

Demo Dynamik mit OSGi Services

Page 41: Warum OSGi?

PojoSRPojo Service Registry

Provider

Consumer

Service Registry

- register- unregister

- get- listen

Name Valuetype api.Echo

availavility 5

Name Valuetype api.Echo

availavility 5... ...

Page 42: Warum OSGi?

Remote ServicesProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

Host����������� ������������������  A

Page 43: Warum OSGi?

Remote ServicesProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

service.exported.interfaces=*

Host����������� ������������������  A

Page 44: Warum OSGi?

Remote ServicesProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

service.exported.interfaces=*

Distribution Provider Impl. (ECF)

Host����������� ������������������  A

Page 45: Warum OSGi?

Remote ServicesProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

listen

service.exported.interfaces=*

Distribution Provider Impl. (ECF)

Host����������� ������������������  A

Page 46: Warum OSGi?

Remote ServicesProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

listen

get

service.exported.interfaces=*

Distribution Provider Impl. (ECF)

Host����������� ������������������  A

Page 47: Warum OSGi?

Remote ServicesProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

listen

get

service.exported.interfaces=*

Distribution Provider Impl. (ECF)

endpoint

Host����������� ������������������  A

Page 48: Warum OSGi?

Remote ServicesProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

exported����������� ������������������  service

listen

get

service.exported.interfaces=*

Distribution Provider Impl. (ECF)

endpoint

Host����������� ������������������  A

Page 49: Warum OSGi?

Remote ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

exported����������� ������������������  service

listen

get

service.exported.interfaces=*

API����������� ������������������  Bundle

Distribution Provider Impl. (ECF)

endpoint

Host����������� ������������������  A Host����������� ������������������  B

Page 50: Warum OSGi?

Remote ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

exported����������� ������������������  service

listen

get

service.exported.interfaces=*

API����������� ������������������  Bundle

Distribution Provider Impl. (ECF)

endpoint

Host����������� ������������������  A Host����������� ������������������  B

Page 51: Warum OSGi?

Remote ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

exported����������� ������������������  service

listen

get

service.exported.interfaces=*

API����������� ������������������  Bundle

Distribution Provider Impl. (ECF)

endpoint

register

Host����������� ������������������  A Host����������� ������������������  B

Page 52: Warum OSGi?

Remote ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

exported����������� ������������������  service

listen

get

service.exported.interfaces=*

API����������� ������������������  Bundle

Distribution Provider Impl. (ECF)

endpoint

register

to����������� ������������������  endpoint

Host����������� ������������������  A Host����������� ������������������  B

Page 53: Warum OSGi?

Remote ServicesConsumer����������� ������������������  BundleProvider����������� ������������������  BundleAPI����������� ������������������  Bundle

exported����������� ������������������  service

listen

get

service.exported.interfaces=*

API����������� ������������������  Bundle

imported����������� ������������������  service

Distribution Provider Impl. (ECF)

endpoint

register

to����������� ������������������  endpoint

Host����������� ������������������  A Host����������� ������������������  B

Page 54: Warum OSGi?

Remote Services Demo

Page 55: Warum OSGi?

OSGi Tooling...

Page 56: Warum OSGi?

Bndtools

Semantic VersioningInstant Builder Integrated Testing

OBR ResolvingRepositoriesImport Analysis

Page 57: Warum OSGi?

Warum OSGi?1. Modules, Extension, Plug-ins, Plattformen

2. Services, Service Registry, Dynamik Instance Coupling

3. Einfachere Entwicklung keine Restarts

Page 58: Warum OSGi?

“Warum OSGi?

- BJ Hargrave, IBM Peter Kriens, aQute

... because it is a better way to develop

software ...“

Page 59: Warum OSGi?

Q&A

Twitter @tux2323

Page 60: Warum OSGi?

Ressourcen• OSGi Alliance

http://www.osgi.org/

• OSGi in Action (ISBN 1933988916)Richard S. Hall, Karl Pauls, Stuart McCulloch, and David Savage

• Why OSGi? BJ Hargrave (IBM), Peter Kriens (aQute)http://www.slideshare.net/bjhargrave/why-osgi

• OSGi: Not Easy Enough to Use. Not as Productive as it Should Be, Rod Johnsonhttp://www.theserverside.com/news/2240037102/OSGi-Not-Easy-Enough-to-Use-Not-as-Productive-as-it-Should-Be

• Bndtools http://bndtools.org/

• OSGi Demo Mars Robot Projecthttp://code.google.com/a/eclipselabs.org/p/occ/

• PojoSRhttp://code.google.com/p/pojosr/