rogue bundles
DESCRIPTION
Slides for www.eclipsecon.org/europe2011/sessions/rogue-bundles-go-jailTRANSCRIPT
Rogue Bundles: Go to Jail
Isolating bundles in OSGI 4.3 / eclipse equinox 3.7
Eclipseconeurope2011 1
Who we are
• Tobias Jenkner, edmPRO
• Matthias Pickel, Piterion GmbH
• Eclipse RCP Integration project at Daimler AG
Eclipseconeurope2011 2
Integrating existing osgi bundles
Eclipseconeurope2011
Eclipse Application
Plugin B1 Plugin A1
Plugin A2 Plugin B2 Plugin B3
Plugin C Version 1.1.1
Plugin C Version 2.0.1 …
…
…
…
…
… …
…
… …
…
… …
…
…
…
…
…
…
…
…
…
…
…
…
…
… Integration Sideeffects ?
3
Demo
Eclipseconeurope2011 4
Integrated Eclipse Application A & B Eclipse Application A Eclipse Application B
Integrating existing osgi bundles
defaulthttpparams.b defaulthttpparams.a
Provide: DefaultHttpConnectionFactory
httpclient.a
Require: http-connection-timeout = 100
httpclient.b
Provide: DefaultHttpConnectionFactory
Require: http-connection-timeout = 5000
? Conflicting Requirements
& capabilities
Eclipseconeurope2011 5
Conflicting capabilities
• Multiple instances of OSGI services
• Multiple instances of Singleton-Bundles
• Multiple exports of a package
Conflicting requirements
• Different implementations of an OSGI service
• Multiple instances of static variables (e.g. for containing different configuration data)
• Incomplete versioning metadata
Eclipseconeurope2011 6
→ Write once …. break in integration scenario ?
Solutions ?
• Change the existing osgi bundles – Not always possible (source code not available)
– Cost, time, ….
• Rogue bundles: Go to Jail!
– Create isolated regions (jailcells) in our OSGI 4.3 runtime
Eclipseconeurope2011 7
Integrated Eclipse Application A & B
OSGI Runtime isolation
Eclipse Framework core components
Eclipseconeurope2011 8
defaulthttpparams.b defaulthttpparams.a
Provide: DefaultHttpConnectionFactory
httpclient.a Require: http-connection-timeout = 100
httpclient.b
Provide: DefaultHttpConnectionFactory
Require: http-connection-timeout = 5000
Demo
Eclipseconeurope2011 9
OSGI 4.3 Framework Hooks
Eclipseconeurope2011 10
ResolverHook
Eclipseconeurope2011 11
Create a new ResolverHook instance for every resolve process
Decide if more than one instance of a singleton bundle may be installed
Decide how bundles may be wired.
ResolverHook
org.osgi.framework.hooks.resolver.ResolverHook
• void filterSingletonCollisions(
BundleCapability singleton, Collection<BundleCapability> collisionCandidates):
Allow one instance of singleton-bundles to be installed in every Bundle-Jail-Cell.
• void filterMatches( BundleRequirement requirement, Collection<BundleCapability> candidates):
Do not allow to wire bundles between different Bundle-Jail-Cells.
• void filterResolvable(Collection<BundleRevision> candidates);: not important for bundle jails
• void end(): lifecycle method not important for bundle jails
Eclipseconeurope2011 12
Find & Event Hooks
• BundleContext.getService… -> Service FindHook
• BundleContext.getBundles(…)-> Bundle FindHook
• ServiceEvents -> Service EventListenerHook
• BundleEvents -> Bundle EventHook
Eclipseconeurope2011 13
BundleJail implementation Implementation of the Hook-Interfaces
→ Use the query part of the bundle install URL → Allows a bundle to be installed multiple times from the same location into
different jail-cells → The install URL is available in the hooks
Eclipseconeurope2011 14
Integrated Eclipse Application A & B
Eclipse Framework core components
Plugin B1 Plugin A1
Provide X
Plugin A2
Require X
Plugin B2
Provide X
Require X
How do the Hook interfaces know which bundle-jail-cell a bundle belongs to?
Open questions P2 integration: Install bundles into jails
• Specify query part of the URL in Config.ini / bundles.info
• P2 installation: Specify BundleJailCell / region in P2-Metadata ?
Eclipseconeurope2011 15
Open questions
• Eclipse extension registry: mulitple singletons -> multiple instances of the same extensions?
– Could be implemented with equinox transforms xslt
• Install location is shared between regions
• No PDE tooling support for custom URLs
• …
Eclipseconeurope2011 16
Look around: Equinox Regions
• Isolation Hooks implementations from the equinox team.
• Originally developed for eclipse virgo
• Directed Graph of bundle regions
Eclipseconeurope2011 17
Look around
• Google chrome: Separate process for every tab
-> Isolation through separate JVM instances ?
-> JSR 121: JVM Isolation API
-> Not yet implemented in Oracle JVM
Eclipseconeurope2011 18
Thank you !
• Questions ?
• Democode: https://github.com/tobias-jenkner/org.eclipse.ece2011.roguebundles
Eclipseconeurope2011 19