Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi...

44
Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine Software for Smartphones and Desktop Systems Doreen Seider (DLR - German Aerospace Center) ApacheCon NA 2011 (Vancouver, 11/11/2011)

Transcript of Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi...

Page 1: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 1ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Using OSGi to Build Better SoftwareLessons from a Telemedicine Software for Smartphones and

Desktop Systems Doreen Seider (DLR - German Aerospace Center)

ApacheCon NA 2011 (Vancouver, 11/11/2011)

Page 2: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 2ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Outline

What software did we want to have?

How did we develop it with OSGi?

What did we learn?

Page 3: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 3ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Page 4: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

What kind of software did we want to have?

ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Slide 4

Page 5: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 5

ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Telemonitoring Software

Supports remote monitoring of patients (e.g. in rural areas)

Captures vital sign of patients from medical devices

Sends measurements to doctors sitting in a medical service center

Executable on mobile devices and desktop systems

Supports any kind of medical device and medical service center

Page 6: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 8ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

In Comparison to That: Flexible Telemonitoring Software

Page 7: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 9ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Flexible Telemonitoring Software Technology

Plug&Care Connector

Page 8: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 10ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Plug&Care Connector Requirements

1. Both on smartphones (like Android or Windows Mobile) and on desktop system executable

2. Support of any device and service center – even later on – without modification of the Plug&Care Connector

Page 9: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

How did we develop it with OSGi?

ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Slide 11

Page 10: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 12ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Plug&Care Connector‘s Architecture

Page 11: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 13ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Bundles and Services

OSGi is specification of a modular service platform written in Java

„modular“

It is a module layer above the Java package layer

Classes are assembled to packages packages are assembled to bundles (modules) bundles are assembled to applications

Page 12: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 14ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Bundles and Services

By default bundles are totally encapsulated

Bundles can make use of each other by explicit exports and imports of packages

Page 13: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 15ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Bundles and Services

OSGi is specification of a modular service platform written in Java

„service“

In a perfect world bundles make use of each other via services

Eliminates direct dependencies to each others implementation

Page 14: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 16ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Bundles and Services

Page 15: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 17ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Bundles and Services

Service definition and implementation are separated to each other

No direct implementation dependencies

Enables loose coupling

Important for assembling bundles (jars) to applications

Page 16: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 18ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Bundles and Services

Page 17: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 19ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Declarative Services (DS)

OSGi Runtime calls the bundle and not other way around

Page 18: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 20ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Declarative Services (DS)

Bundles provide a set of so called component descriptions

A component is a Java class

Each describes which services a component provides and consumes

OSGi runtime injects all required services at start up

Page 19: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 21ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi Principles: Declarative Services (DS)

Benefits of Declarative Services

Less complexity in own code

Better testing (no mock up of OSGi runtime needed)

Page 20: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 22ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Fulfilling Requirements with the help of OSGi

1. Both on smartphones (like Android or Windows Mobile) and on desktop system executable

Platform independency by realizating it as OSGi application

OSGi serves as an abstraction layer of underlying diversity

Using different implementations of OSGi for different platforms

Assembling bundles to the Plug&Care Connector application according to its deployment platform

Page 21: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 23ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Used OSGi Implementations: Equinox

For desktop

Eclipse Software Foundation

OSGi implementation under Eclipse

Decision was made due to experiences from other software we develop

Page 22: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 24ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Used OSGi Implementations: mBS Mobile

For Smartphones

ProSyst company (http://prosyst.com)

Android, Windows Mobile, Nokia S60

http://dz.prosyst.com/mbsmobile/

Decision was made due to supported platforms at that time and due to development status

Page 23: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 25ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Used OSGi Implementations: mBS MobileIntegration in Android

Page 24: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 26ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Used OSGi Implementations: mBS MobileOSGi Management on Android

Page 25: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 27ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Used OSGi Implementations: mBS MobileOSGi Applications on Android

Page 26: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 28ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi-Stack: mBS MobileDevelopment Environment in Eclipse

Page 27: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 29ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

OSGi-Stack: mBS MobileDevelopment Environment in Eclipse

Page 28: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 30ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorAbstraction with the use of Console

OSGi comes with a console for management purposes

It is useful for testing i.e. interacting with the application if no GUI is available yet

Own commands can be provided

Different OSGi implementations might have different console APIs

Abstraction of console APIs is needed to hide them for the underlying application layers writing to the console

Page 29: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 31ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorAbstraction with the use of Console

Layered architecture of affected bundles

Page 30: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 32ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorAbstraction with the use of Device Communication

Measurements are captured via Bluetooth

There are different bluetooth implementations on different devices

Later on not only Bluetooth, but USB should be supported as well

Abstraction of communication layer and Bluetooth implementations is needed to ensure driver implemenentation must not be changed

Page 31: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 33ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorAbstraction with the use of Device Communication

Layered architecture of affected bundles

Page 32: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 34ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorAbstraction with the use of Console and Device Communication

Deployment

Page 33: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 35ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Fulfilling Requirements with the help of OSGi

1. Both on smartphones (like Android or Windows Mobile) and on desktop system executable

Platform independency by realizating it as OSGi application

OSGi serves as an abstraction layer of underlying diversity

Using different implementations for different platforms

2. Support of any device and service center – even later on – without modification of the Plug&Care Connector

Establish plugin concept

Get plugins with help of modularity of OSGi

Handle plugins (registration) by the use of dependency injection provided by OSGi (Declarative Services)

Page 34: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 37ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorPlugin and Registry Concept using the Example of Driver

How did we realize it?

Page 35: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 38ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorPlugin and Registry Concept using the Example of Driver

Page 36: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 39ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorPlugin and Registry Concept using the Example of Driver

What does a driver developer need to do?

Implement the driver interfaces provided by Plug&Care Connector

Provide a component description like that:

<component name=„Driver A“>

<implementation class="de.pncc.plugins.drivers.DriverA"/>

<service>

<provide interface="de.pncc.drivers.Driver"/>

</service>

</component>

Page 37: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 40ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorPlugin and Registry Concept using the Example of Driver

What does the Plug&Care Connecor do?

Provides component description like that:

<component name=„Driver Registry„<reference name="de.pncc.driver„

interface="de.pncc.drivers.Driver„bind="addDriver„

unbind="removeDriver</component>

Implements bind and unbind method to e.g., store the driver in a list

Page 38: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 41ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Designing Plug&Care ConnectorPlugin and Registry Concept using the Example of Driver

What does OSGi do?

Everything elselike listen to new driver bundles, retrieving there provided driver services, inject them to the right place, handles uninstalled driver bundles, …

Page 39: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

What did we learn?

ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Slide 44

Page 40: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 45ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

What did We Learn?

Living out OSGi principles is a good base for building better software (in terms of maintance and deployment).

Page 41: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 46ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Living out OSGi PrinciplesServices

Use services

Seperate service interface and service implementation

Allows abstraction and loose coupling

Makes application

More robust against changes

Deployable in different environments just by assempling different kind of jar files

Page 42: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 47ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Living out OSGi PrinciplesDeclarative Services

Prerequisite is usage of services

Make use of dependency injection

Let other maintain the code for dependency handling

Get your code free from OSGi API

Makes application

Easier to test by injecting stub or mock objects

More robust because fewer lines of code (every reduced line of code, reduces the chance for a bug)

Easier to understand and use by third party developers knowing nothing about OSGi

Page 43: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 48ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011

Living out OSGi PrinciplesEncapsulation

Make only those code public which is really intended to be public

Hide as much as possible from the outer world

In perfect word only the (service) interfaces are public

Makes application

More robust against changes because third party code can only be depend on a little part of your applications‘s implementation

Architecture smarter, because you need to think about it in more detail

Page 44: Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011 Using OSGi to Build Better Software Lessons from a Telemedicine.

Slide 49ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > 11.11.2011