moduarlity patterns with osgi

Post on 17-Jul-2015

1.700 Views

Category:

Software

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Modularity

patterns

with OSGi

Paul Bakker@pbakker

Agenda µServices architecture Whiteboard pattern Reusable and configurable services Extender pattern Real world example

Classeshttps://www.flickr.com/photos/crdot/

Modules

https://www.flickr.com/photos/128326674@N06/

http://www.carpartsireland.ie/uploads/Reardriftspoiler144cm003.jpg

Service contract

Module

Implementation classes

Hide implementation

details

Make imports and

exports explicit

Export only public interfaces

Import public interfaces

provided by others Export-Package: example.api;version=“1.0.0"

Import-Package: some.otherapi;version=“[1.0,2)"

ServiceRegistry

Bundle registering a service

Bundle using a service

PublishMyInterface

LookupMyInterface

OSGi Service Registry

Demo

Components only communicate using service APIs

Implementation should be replaceable!

A simple example

ResultsREST

ResultsStorage

StatsAggregator

StatsREST

TracksREST

TracksStorage

Services may use multiple other services

Demo

Always  be  prepared  for  dynamics

Services must

contain their own data

ResultsStorage

TracksStorage

ResultsStorage

TracksStorage

Examples

MongoDB Each service owns a

collection

Relational

Each service owns a

set of tables

ResultsStorage

TracksStorage

...

...

Table A

...

...

Table B

...

...

Table C......

Table D

...

...

Table F

...

...

Table E

...

...

Table G

Whiteboard

Pattern

PluginRegistry

Plugin Plugin Plugin

Whiteboard

Use multiple services with the same interface

Demo

Real life examples

Amdatu REST Apache Felix HTTP Whiteboard Amdatu Scheduling Amdatu Bootstrap plugins Apache Felix Gogo commands

Configuration

What if

all services

do the same thing

with different config?

ManagedServiceFactory

Config

Config

Config

Component

Component

Component

Managed Service Factory

Extender  Pattern

Real life examples

Providing static web resources Amdatu JPA (weaving) Templates in Amdatu Bootstrap

What if

my bundles don’t

really “do” anything?

Resourcebundle A

Resourcebundle B

Extender

Component

Component

Component

Extender pattern

Demo

Do NOT overuse

Adding extenders is like adding a DSL: Powerful and confusing.

BootstrapCore

AmdatuPlugin

Dependency Manager

Plugin

ProjectPlugin

WorkspacePlugin

BaseliningPlugin

BootstrapWeb backend

BootstrapShell

TemplateExtender

Projecttemplates

Workspacetemplates

BootstrapWeb UI

bnd

Plugin Whiteboard

...Plugin

Real world

example

Bootstrap

A modular architecture gives us:

Maintainability

Extensibility

Freedom to change

Wrap up

But what if I want

Spring

EJB

…?

Just don’t… You really don’t need to.

Eclipse OSGi plugin http://bndtools.org/

That’s us http://luminis-technologies.com

Open source OSGi components

http://www.amdatu.org/

Amdatu

Paul Bakker paul.bakker@luminis.eu @pbakker

top related