OSGi Subsystems - EclipseCon Europe 2013 |

70
OSGi Subsystems from theory to practice Glyn Normington Eclipse Virgo Project Lead SpringSource/VMware 1

Transcript of OSGi Subsystems - EclipseCon Europe 2013 |

Page 1: OSGi Subsystems - EclipseCon Europe 2013 |

OSGi Subsystemsfrom theory to practiceGlyn NormingtonEclipse Virgo Project LeadSpringSource/VMware

1

Page 2: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Software rots

2

Page 3: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

modularity helps

3

Page 4: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

but ...

4

Page 5: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 5

A clean design

Page 6: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 6

without enforcement

Page 7: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 7

works fine for a while

Page 8: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 8

then starts to decay

Page 9: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 9

and soon

Page 10: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 10

the rot sets in

Page 11: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 11

and spreads

Page 12: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 12

and worsens

Page 13: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 13

until the original design

Page 14: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 14

has gone.

Page 15: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

OSGi Subsystems to the rescue

15

Page 16: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Subsystem: identified manageable optionally scopedgroup of bundles

16

Page 17: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

subsystemsspec

17

Page 18: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

subsystemsreference

implementation

18

Page 19: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

subsystemsreference

implementation

18

Page 20: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Now some theory

19

Page 21: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

and practice

20

Page 22: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

followed by

21

•getting started• the future

Page 23: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

TheorySubsystem Types

22

Page 24: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Feature Subsystems

Feature

bundle

bundle bundle

bundle

Scoping:•None

23

Page 25: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Feature Subsystems

Feature

bundle

bundle bundle

bundle

24

A depends on B

bundle Bbundle A

• bundle• package• capability• service

Notation

Page 26: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Feature Subsystems

Feature

bundle

bundle bundle

bundle

Scoping:•None

25

Page 27: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Application Subsystems

int x;{ int y;}

26

Page 28: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Application Subsystems

Application

bundle

bundle

bundle

bundle

Scoping:•No exports•Automatic

imports

27

{ }

Page 29: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Composite Subsystems

Composite

bundle

bundle bundle

bundle

Configurablescoping

28

Page 30: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

PracticeSubsystem Types

29

Page 31: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Feature Subsystems

Useful for:

• Grouping dependencies

• Sharing infrastructure

• Avoiding uses constraint failures

Feature

bundle

bundle bundle

bundle

30

Page 32: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Application Subsystems

Useful for top layer of the system

Avoid duplicating contents

• Reduces sharing

• Complicates update

• Leads to resolution errors

Application

bundlebundle

Feature

bundlebundle

Application

bundlebundle

31

Page 33: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Composite SubsystemsUseful for special infrastructure

Not for general use

• Complex

• Can duplicate infrastructure

• extenders

• management bundles

Composite

bundle

bundle bundle

bundle

32

Page 34: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 33

bundlespackages

capabilitiesservices

services

kernel

user region compositesubsystem

Page 35: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

TheorySubsystem Content and

Dependencies

34

Page 36: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Subsystem Content• By value in a subsystem archive

or

• By reference to a repository

35

Page 37: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Dependencies

• Subsystem content dependencies

• Installed from repository

36

Page 38: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

PracticeSubsystem Content and

Dependencies

37

Page 39: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Subsystem Content (by value)

• Easy to deploy

• Limits sharing

• Harder to update

38

Page 40: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Repository Content

• Convenient during development

• Avoids bloat

• Generally preferable

39

Page 41: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

TheoryNested

Subsystems

40

Page 42: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Nested Subsystems• So far all subsystems have been

children of the ‘root’ subsystem

Root

Application

bundlebundle

Feature

bundlebundle

Application

bundlebundle

41

Page 43: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Nested Subsystems

• Unlimited nesting

• Sharing determined by the child

42

Page 44: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

PracticeNested Subsystems

43

Page 45: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Nested Subsystems• Features useful for grouping other subsystems

Root

Feature

Application

bundle

bundle

bundle

Application

bundle

bundle

bundle

bundle

44

Page 46: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Nested Subsystems• Nested features useful for logical grouping

Root

Application

bundlebundle

Feature

bundlebundle

Root

Feature

bundlebundle

Feature

bundlebundle

45

Page 47: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Nested Subsystems• Nested applications useful for scoping

Root

Application

bundlebundle

Application

bundlebundle

bundle

46

Page 48: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

More Theory

47

Page 49: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Subsystem States

48

installing

installed uninstalling

resolving resolved

starting stopping

active

uninstalled

install failed

install

start

start

stop

uninstall

uninstall

Page 50: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

RegionsRegion, group of bundles:

• scoped subsystems

• root subsystem

Directed graph; arcs are filters

Region context bundle

49

Page 51: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Getting Started

50

Page 52: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Aries Subsystems

on Virgo kernel

https://github.com/glyn

51

Page 53: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Feature

52

Subsystem-SymbolicName: hello.feature.subsystem

Subsystem-Type: osgi.subsystem.feature

Subsystem-Content: hello

Page 54: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Application

53

Subsystem-SymbolicName: hello.application.subsystem

Subsystem-Type: osgi.subsystem.application

Subsystem-Content: hello

Page 55: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Composite

54

Subsystem-SymbolicName: hello.composite.subsystem

Subsystem-Type: osgi.subsystem.composite

Subsystem-Content: hello;version="[1,1]"

Import-Package: org.osgi.framework

Page 56: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Nested Subsystem

55

Subsystem-SymbolicName: hello.nested.composite.subsystem

Subsystem-Type: osgi.subsystem.composite

Subsystem-Content: hello;version="[1,1]",

hello.application.subsystem;

type="osgi.subsystem.application";

version="[0,0]"

Import-Package: org.osgi.framework

Page 57: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Region Digraph

56

kernel

user region

application composite nested composite

application

Page 58: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Alternatives

57

Page 59: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Technology Stack

58

Equinox region bundle

Aries Subsystems Virgo Kernel

Page 60: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

VirgoStandard Virgo Equivalent

Feature Unscoped plan

Application Scoped plan or PAR

Composite User region

Nesting Nested plans

Repository Repository

59

Page 61: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Equinox Region Support• org.eclipse.equinox.region

• RegionDigraph service

• Persistence

• JMX mxbeans

60

Page 62: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Back to software rot

61

Page 63: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Subsystems

62

Page 64: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

guide evolution

63

Page 65: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

and discourage rot.

64

Page 66: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

The Future

65

Page 67: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Future Work Items

66

Spec topics

•Extenders•Weaving and dynamic imports•Service dependency determination•Thread context class loaders•Config Admin

Tooling support

Page 68: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems 67

ThanksJohn Ross - Aries SubsystemsGraham Charters - Subsystems spec

Page 69: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

OSGi R5 Enterprise Specificationhttp://www.osgi.org/Download/Release5

Arieshttp://aries.apache.org/

Aries Subsystems on Virgo Kernelhttps://github.com/glyn

Virgohttp://www.eclipse.org/virgo

Equinox Region Bundlegit://git.eclipse.org/gitroot/equinox/rt.equinox.bundles.git

68

Page 70: OSGi Subsystems - EclipseCon Europe 2013 |

@glynnormingtonOSGi Subsystems

Questions?

69