multi-bundle scoping in osgi

57
50 μm lead sulphide assemblies each containing ~10 8 nanoparticles Multi-Bundle Scoping in OSGi Glyn Normington Copyright VMware Inc. 2011. Licensed under the Eclipse Public License

Upload: glynnormington

Post on 23-Jan-2018

2.496 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Multi-bundle Scoping in OSGi

50 µm lead sulphide assemblies each containing ~108 nanoparticles

Multi-Bundle Scoping in

OSGiGlyn Normington

Copyright VMware Inc. 2011. Licensed under the Eclipse Public License

Page 2: Multi-bundle Scoping in OSGi

Agenda

•Modules in Java

•Multi-bundle modules

•Scoping mechanisms

•Subsystems

Page 3: Multi-bundle Scoping in OSGi

Modules in Java

Page 4: Multi-bundle Scoping in OSGi

Modularitythe degree to which a system’s components may be separated and recombined

the tightness of coupling between components

the degree to which the system architecture controls the mixing and matching of components

Page 5: Multi-bundle Scoping in OSGi

Modularitythe degree to which a system’s components may be separated and recombined

the tightness of coupling between components

the degree to which the system architecture controls the mixing and matching of components

informationhiding

Page 6: Multi-bundle Scoping in OSGi

Modules in Java• Class

• Package

• JAR

• Class loader

• Module - Java 8

• Larger scale modules?

} OSGi bundle

Page 7: Multi-bundle Scoping in OSGi

Multi-Bundle Modules

Page 8: Multi-bundle Scoping in OSGi

Information to Hide

• Bundle

• Package

• Generic capability

• Service

Page 9: Multi-bundle Scoping in OSGi

Example 1

Feature

bundle

bundle

bundle

bundle

Page 10: Multi-bundle Scoping in OSGi

Example 2

Scoped App

bundle

bundle

bundle

bundle

Page 11: Multi-bundle Scoping in OSGi

Example 3

Kernel

bundle

bundlebundle

bundle

Page 12: Multi-bundle Scoping in OSGi

Scoping Mechanisms

Page 13: Multi-bundle Scoping in OSGi

Scoping Mechanisms• x-internal/x-friends

• metadata rewriting

• composite bundle

• framework hooks

• region digraph

Page 14: Multi-bundle Scoping in OSGi

Eclipse x-* Directives• Export-Package directives

• Enforced by framework

• x-internal

• x-friends

• Non-standard

• Naming friends is brittle

➡ Standard, maintainable mechanism

Page 15: Multi-bundle Scoping in OSGi

Metadata RewritingHide internals:

• Decorate referents

• Bundles and packages

• Generic capabilities

• Fix references

• Use service registry hooks

Page 16: Multi-bundle Scoping in OSGi

Metadata Rewritingin Virgo

Demo ...

Page 17: Multi-bundle Scoping in OSGi

Metadata RewritingIssues:

• Suitable for isolated applications only

• Intrusive

• Complicates bundle update

• Can be coded round

• Non-standard

➡ Standard scoping in the framework

Page 18: Multi-bundle Scoping in OSGi

Composite Bundle• OSGi draft spec

• Prototyped in Equinox, deprecated

• Uses framework instance

• Surrogate bundle represents “parent”

• Used in Virgo 2.1 to isolate the kernel

Page 19: Multi-bundle Scoping in OSGi

Composite BundleIssues:

• Implemented in the framework

• Cannot expose constituent bundles

• Hard to spec portably

➡ Superseded

Page 20: Multi-bundle Scoping in OSGi

Framework Hooks• Part of OSGi 4.3 core

• Control visibility

• Enable framework to be partitioned

• 5 main hooks:

• resolver hook

• bundle find/event hooks

• service find/event hooks

Page 21: Multi-bundle Scoping in OSGi

Framework HooksIssues:

• Low level

• Consistency of hooks

• Coexistence of sets of hooks

➡ Higher level API needed

Page 22: Multi-bundle Scoping in OSGi

Region Digraph

Page 23: Multi-bundle Scoping in OSGi

Graph Theory Interlude

Page 24: Multi-bundle Scoping in OSGi

Tree

Page 25: Multi-bundle Scoping in OSGi

DAG

Page 26: Multi-bundle Scoping in OSGi

Digraph

Page 27: Multi-bundle Scoping in OSGi

Graph

Page 28: Multi-bundle Scoping in OSGi

Region Digraph• Framework hook abstraction

• Bundles partitioned into regions

• Regions connected by filters

• Bundles

• Packages

• Generic capabilities

• Services

Page 29: Multi-bundle Scoping in OSGi

Example Digraphregion A

region B

p1, p2

"allow p1"

p3

Page 30: Multi-bundle Scoping in OSGi

Example Digraphregion A

region B

p1, p2

"allow p1"

p3

visible: p1, p2

visible: p1, p3

Page 31: Multi-bundle Scoping in OSGi

Example Digraph 2region X

region Y

p1, p2

"allow p1, p3"

region Z

"allow p3, p4" p3, p4

Page 32: Multi-bundle Scoping in OSGi

Example Digraph 2region X

region Y

p1, p2

"allow p1, p3"

region Z

"allow p3, p4" p3, p4

visible: p1, p2, p3, p4

visible: p1, p3

Page 33: Multi-bundle Scoping in OSGi

Region Digraph

• Equinox bundle

• Runs on standard framework hooks

• Persistent

• JMX

Page 34: Multi-bundle Scoping in OSGi

Region Digraph Uses

• Virgo 3.0 kernel/user region

• Apache Aries “subsystems” prototype

• Standalone:

“We're using [the region digraph] essentially for a fully multi-tenant plugin system to Web applications.”

Robert Sauer

kernel

user region

p1, p2 s1, s2b1, b2

"allow p1, s1, b1"

p3s3, s4

b3

"allow s3"(service of p1 type)

Page 35: Multi-bundle Scoping in OSGi

Region Digraph in VirgoDemo ...

Page 36: Multi-bundle Scoping in OSGi

Region Digraph APIpublic interface RegionDigraph ... {

Region createRegion(String regionName) throws BundleException;

RegionFilterBuilder createRegionFilterBuilder();

...}

public interface Region {

void connectRegion(Region headRegion, RegionFilter filter)throws BundleException;

...}

Page 37: Multi-bundle Scoping in OSGi

Region DigraphIssues:

• Too low level for application use

• Non-standard

➡ Standard, high-level programming model

Page 38: Multi-bundle Scoping in OSGi

Subsystems

Page 39: Multi-bundle Scoping in OSGi

Why Subsystems?5 projects have multi-bundle constructs

• Poor portability

• Inconsistent terminology

• Diverse function

➡ Standard

Page 40: Multi-bundle Scoping in OSGi

Subsystems• OSGi Enterprise Expert Group

• Scoping based on composite bundles framework hooks

• Public draft available (“RFC 152”)

Page 41: Multi-bundle Scoping in OSGi

What is a Subsystem?• Group of constituents with dependencies

• Constituents: bundles, subsystems, ...

• Dependencies: loosely coupled pre-reqs

• Named and versioned

• Defined lifecycle

Page 42: Multi-bundle Scoping in OSGi

Subsystem Scoping

Subsystem type Scoping

application contents hidden

composite configurable

feature none

Page 43: Multi-bundle Scoping in OSGi

Example 1

Application

Feature

Page 44: Multi-bundle Scoping in OSGi

Example 2

Feature A

Feature B

Feature C

Page 45: Multi-bundle Scoping in OSGi

Example 3

Application A

Application B

Composite C

Page 46: Multi-bundle Scoping in OSGi

Scoping and RegionsSubsystem scoping can be

• defined in terms of

• implemented using

a region digraph

Page 47: Multi-bundle Scoping in OSGi

Complex Scoping 1App3

FeatureP

FeatureQ

FeatureR

CompositeC

Page 48: Multi-bundle Scoping in OSGi

Region Digraph

Region C

Region A3App3

FeatureP

FeatureQ

FeatureR

CompositeC

App3

FeatureP

FeatureQ

FeatureR

CompositeC

Page 49: Multi-bundle Scoping in OSGi

Complex Scoping 2Root

Application A

Application BComposite C

Composite D

Application E

Page 50: Multi-bundle Scoping in OSGi

Region Digraph

RootApplication A

Application BComposite C

Composite D

Application E

Comp DApp A

Root

App E

Comp CApp V

Page 51: Multi-bundle Scoping in OSGi

Dependencies

CompositeF

FeatureX

FeatureY

App2App1

Page 52: Multi-bundle Scoping in OSGi

Installing Dependencies

CompositeF

App2App1

Root"accept

transitive"

Page 53: Multi-bundle Scoping in OSGi

Installing Dependencies

CompositeF

App2App1

Root"accept

transitive"

FeatureX FeatureY

Page 54: Multi-bundle Scoping in OSGi

Region DigraphRegion

A2Region

A1Region F

FeatureX

FeatureYApp2App1

CompositeF

CompositeF

FeatureX

FeatureY

App2App1

Page 55: Multi-bundle Scoping in OSGi

ConclusionModularity in Java:

• Class, package, JAR, class loader

• Modules in Java 8

• Larger modules?

Modularity in OSGi:

• Bundles

• Multi-bundle modules

• Subsystems

Page 56: Multi-bundle Scoping in OSGi

Further Information• Public draft of subsystems (RFC 152)

• http://www.osgi.org/Download/File?url=/download/osgi-early-draft-2011-09.pdf

• Region digraph

• http://underlap.blogspot.com/2011/05/equinox-digraph-ready-for-use.html

• Eclipse Virgo and the region digraph

• https://bugs.eclipse.org/bugs/show_bug.cgi?id=330776

• Apache Aries use of region digraph

• https://issues.apache.org/jira/browse/ARIES-644

• Multi-module modules and Java 8

• http://mail.openjdk.java.net/pipermail/jigsaw-dev/2011-October/001564.html

Page 57: Multi-bundle Scoping in OSGi

Thanks to...• Wikipedia image courtesy of Wikipedia.org

• Field of Flowers by Paul Podsiadlo and Elena Shevchenko, courtesy of Argonne National Laboratory