Services first migration to osgi - osgi users forum uk 16-nov2011
Upcoming SlideShare
Loading in...5
×
 

Services first migration to osgi - osgi users forum uk 16-nov2011

on

  • 1,632 views

Presentation by Peter Kriens at OSGi Users' Forum UK meeting on Nov 16, 2011 in London....

Presentation by Peter Kriens at OSGi Users' Forum UK meeting on Nov 16, 2011 in London.

Abstract: The OSGi Service Platform is a standard that specifies a comprehensive model of modules that communicate through a powerful, no overhead, Inter Module Communication mechanism: OSGi Services. OSGi enforces module-level isolation that forbids ad hoc cross-module class loading but this conflicts with prevalent Java software patterns that assume application-wide class visibility. OSGi Connect proposes the OSGi programming model without the module-level isolation. This presentation will show you how you can use OSGi Connect to begin to modularize your existing applications with the OSGi programming model with a minimal upfront investment.

Statistics

Views

Total Views
1,632
Views on SlideShare
1,632
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Services first migration to osgi - osgi users forum uk 16-nov2011 Services first migration to osgi - osgi users forum uk 16-nov2011 Presentation Transcript

  • Services-First Migration to OSGi BJ Hargrave (IBM) Peter Kriens (aQute)woensdag 16 november 11
  • Agenda • Modularity Maturity Model • The Brick Wall • Couplings • µServices • What Broker? • Example • Conclusionwoensdag 16 november 11
  • Modularity Maturity Model • 1 Ad Hoc • 2 Managed • 3 Contracts • 4 Fences Page 2 OSGi Alliance Marketing © 2008-2011 . All Rights Reserved, © IBM Corp. 2011 21.09.2011 • Inspired by Graham Charters’ excellent OSGi Community Event 2011 5 Optimize presentation @ http://slidesha.re/q8EHFpwoensdag 16 november 11
  • Modularity Maturity Modelwoensdag 16 november 11
  • 1. Ad Hoc • Flat, manual class path • Single name space • Full visibility and normal accessibility • Monolithic • Highly coupled • Split Packages • Add/Shuffle JARs until it workswoensdag 16 november 11
  • 1. Ad Hoc • Flat, manual class path • Single name space e l l H • Full visibility and normal accessibility • Monolithic AR • • Highly coupled Split Packages J • Add/Shuffle JARs until it workswoensdag 16 november 11
  • 2. Managed • Treat JARs as a module • JAR Identity • Naming • Versioning • Dependencies • Repositorieswoensdag 16 november 11
  • 2. Managed a d • Treat JARs as a module n l o w he t • JAR Identity • Naming D o t • Versioning r n e • Dependencies n t e • Repositories iwoensdag 16 november 11
  • 3. Contracts • Interface based design, POJOs • Provide contracts for each connection between JARs • Implementation details inside the JAR • Versioning on contractswoensdag 16 november 11
  • 3. Contracts • d e r a Interface based design, o POJOs • Provide contracts for l s s k s c a a each connection l h between JARs • Implementation details inside the JAR c • Versioning on contractswoensdag 16 november 11
  • 4. Fences • Explicitly Import/Export packages • Explicitly specify requirements and capabilities • Enforce the module boundaries • Semantic Versioning • Side-by-side versioning supportedwoensdag 16 november 11
  • 4. Fences • Explicitly Import/Export packages • Explicitly specify requirements and capabilities o d! • • Enforce the module boundaries Semantic Versioning Go • Side-by-side versioning supportedwoensdag 16 november 11
  • 5. Optimize • Exploit concepts for modules and contracts • Delegated Control • Optimize the code base to leverage new patterns: • Extender • Whiteboard • Repeatwoensdag 16 november 11
  • 5. Optimize • Exploit concepts for modules and contracts • Delegated Control • Optimize the code base to leverage new patterns: • Extender • Whiteboard • Repeatwoensdag 16 november 11
  • Today 1. Ad Hoc 2. 3. Managed Contracts 4. Fences 5. Optimizewoensdag 16 november 11
  • Today 1. Ad Hoc Enterprise DI vn ,C m ice ing 2. 3. Ivy Managed Contracts gu r saw sp jig 4. Fences 5. Optimizewoensdag 16 november 11
  • Today 1. Ad Hoc Enterprise DI vn ,C m ice ing 2. 3. Ivy Managed Contracts gu r OSGi saw s p jig 4. Fences 5. Optimizewoensdag 16 november 11
  • Today 1. Ad Hoc Enterprise DI vn ,C m ice ing 2. 3. Ivy Managed Contracts gu r OSGi saw s p jig 4. Fences 5. Optimizewoensdag 16 november 11
  • woensdag 16 november 11
  • woensdag 16 november 11
  • Class.forName(String)woensdag 16 november 11
  • Class Space package classwoensdag 16 november 11
  • Class Space package classwoensdag 16 november 11
  • Class Space package classwoensdag 16 november 11
  • Class Space V1 V2woensdag 16 november 11
  • Class Space V1 V2woensdag 16 november 11
  • Class Space V1 V2 Class.forNamewoensdag 16 november 11
  • Class Space V1 V2 x x Class.forNamewoensdag 16 november 11
  • Class Space V1 V2 x x Class.forNamewoensdag 16 november 11
  • Why Class.forName?woensdag 16 november 11
  • Why Class.forName? ! ! ! ! ! ! ! ! ! ! ! ! N G! P LI C O Uwoensdag 16 november 11
  • How to get an Instance? That is the Question!woensdag 16 november 11
  • Couplings modular not Example modular type FooImpl foo; Foo foo = (Foo) instance Class.forName(“FooImpl”) .newInstance();woensdag 16 november 11
  • Type Coupling class Client {} class FooImpl{}woensdag 16 november 11
  • Type Coupling class Client {} class FooImpl{}woensdag 16 november 11
  • Type Coupling class Client {} class FooImpl{} interface Foo{}woensdag 16 november 11
  • Type Coupling class Client {} class FooImpl{} interface Foo{} uses implementswoensdag 16 november 11
  • Type Coupling class Client {} class FooImpl{} interface Foo{} uses implements get instancewoensdag 16 november 11
  • Type Coupling class Client {} class FooImpl{} o r ?l o ut s n einterface Foo{} C s uses implements Is get instancewoensdag 16 november 11
  • Instance Coupling • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  • Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  • Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  • Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  • Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  • Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  • µServices Primitive • Broker Pattern • Direction • Contract • Publish • Find • Bind • Who’s Listening? • Cardinalitywoensdag 16 november 11
  • µServices Primitive • Broker Pattern • Direction • Contract • Publish A S B • Find • Bind • Who’s listening? • Cardinalitywoensdag 16 november 11
  • Patterns • Factory • Listener • Discovery • Distributionwoensdag 16 november 11
  • 5. Optimize Ewoensdag 16 november 11
  • 5. Optimize A B C D E F G H Iwoensdag 16 november 11
  • Back to the Brick Wallwoensdag 16 november 11
  • Migration A B C D E F G H Iwoensdag 16 november 11
  • Migration A B C D E F G H Iwoensdag 16 november 11
  • Migration A B C D E F G H Iwoensdag 16 november 11
  • Migration A B C D E F G H Iwoensdag 16 november 11
  • Migration A B C D E F G H Iwoensdag 16 november 11
  • So we need a broker that runs without fences...woensdag 16 november 11
  • So we need a Broker that runs without Fences...SR o j o Pwoensdag 16 november 11
  • POJOSR • Developed by Karl Pauls • JavaOne presentation 24811 • http://pojosr.googlecode.com • Based on Apache Felixwoensdag 16 november 11
  • Gain • Existing libraries and many bundles work without modification • Bundle (JAR) activation (have their own local main) • µServices • Dynamicity (in µServices) • Extender pattern (react on JAR content) • Migration path to Fences (OSGi) • Existing OSGi and non-OSGi tooling can be usedwoensdag 16 november 11
  • Loss • No dynamic install/uninstall/update • No side-by-side versioning • No module privacy • No explicit dependencies • No Lazy activation • No Bundle classpath • No Native Code supportwoensdag 16 november 11
  • Migrating • Example: extend ant … the tool we all (sometimes) love and (sometimes) hate • We make different <helloXXX/> taskswoensdag 16 november 11
  • Ant Your Service • Base ant • Activator • Extender ant ... ...woensdag 16 november 11
  • Ant Your Service • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  • Ant Your Service • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  • Ant Your Service Class<Task> • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  • Ant Your Service Class<Task> hello activator • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  • Ant Your Service Class<Task> hello activator • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  • Ant Your Service <project name="master"> <path id="bundles"> <fileset dir="bundles"> <include name="*.jar" /> </fileset> </path> <taskdef name="auto" classname="aQute.ant.connect.AutoTask" classpathref="bundles" /> <auto /> <helloActivator /> </project>woensdag 16 november 11
  • Ant Your Service public class Activator implements BundleActivator { public void start(BundleContext context) throws Exception { Properties props = new Properties(); props.put("ant", "helloActivator"); context.registerService(Class.class.getName(), HelloTask.class, props); } public void stop(BundleContext context) throws Exception { } } public class HelloTask extends Task { String message = "Hello Activator"; public void execute() { System.out.println(message); } public void setMessage(String m) { this.message = m; } }woensdag 16 november 11
  • Ant Your Service public class Activator implements BundleActivator { t public void start(BundleContext context) throws Exception { f Properties props = new Properties(); u props.put("ant", "helloActivator"); r context.registerService(Class.class.getName(), c HelloTask.class, props); } public void stop(BundleContext context) throws Exception { } } public class HelloTask extends Task { String message = "Hello Activator"; public void execute() { System.out.println(message); } public void setMessage(String m) { this.message = m; } }woensdag 16 november 11
  • Ant Your Service Class<Task> hello activator • Base ant pojosr pojo ant • Activator • Extender ant ... ...woensdag 16 november 11
  • Ant Your Service Class<Task> hello activator • Base ant pojosr pojo ant hello extendee • Activator • Extender ant ... ...woensdag 16 november 11
  • Ant Your Service Class<Task> hello activator • Base ant pojosr pojo ant hello extendee • Activator Manifest-Version: 1.0 • ant Ant-Task: helloExtender=HelloTask Extender ... ...woensdag 16 november 11
  • Ant Your Service public class HelloTask extends Task { String message = "Hello Extender"; public void execute() { System.out.println(message); } public void setMessage(String m) { this.message = m; } }woensdag 16 november 11
  • Ant Your Service public class HelloTask extends Task { String message = "Hello Extender"; public void execute() { System.out.println(message); } public void setMessage(String m) { this.message = m; } } u ft c r N Owoensdag 16 november 11
  • Conclusion • Moving to Fences is hard because popular instance creation patterns are fundamentally not modular • Services-First approach works without Fences • After completion, moving to Fences is much easierwoensdag 16 november 11
  • Good Fences Make Good Neighborswoensdag 16 november 11
  • Good Fences od ul es Make Good Neighbors mwoensdag 16 november 11
  • Q&Awoensdag 16 november 11