Your SlideShare is downloading. ×
0
Services-First                          Migration to OSGi                               BJ Hargrave (IBM)                 ...
Agenda                  •       Modularity Maturity Model                  •       The Brick Wall                  •      ...
Modularity Maturity                               Model                  •       1 Ad Hoc                  •       2 Manag...
Modularity Maturity                               Modelwoensdag 16 november 11
1. Ad Hoc                  •       Flat, manual class path                  •       Single name space                  •  ...
1. Ad Hoc                  •       Flat, manual class path                  •       Single name space                     ...
2. Managed                  •       Treat JARs as a module                  •       JAR Identity                          ...
2. Managed                                                            a d                  •       Treat JARs as a module ...
3. Contracts                  •       Interface based design,                          POJOs                  •       Prov...
3. Contracts                  •                                                           d e r                           ...
4. Fences                  •       Explicitly Import/Export                          packages                  •       Exp...
4. Fences                  •       Explicitly Import/Export                          packages                  •       Exp...
5. Optimize                  •       Exploit concepts for                          modules and contracts                  ...
5. Optimize                  •       Exploit concepts for                          modules and contracts                  ...
Today                                       1.                                     Ad Hoc                            2.   ...
Today                                                 1.                                               Ad Hoc            E...
Today                                                 1.                                               Ad Hoc            E...
Today                                                 1.                                               Ad Hoc            E...
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 Space                                                  V1   V2                          x                   x       ...
Why Class.forName?woensdag 16 november 11
Why Class.forName?                                                               ! ! !                                    ...
How to get an Instance?                  That is the Question!woensdag 16 november 11
Couplings                                 modular    not Example                                           modular        ...
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{}                                ...
Type Coupling                          class Client {}                     class FooImpl{}                                ...
Type Coupling                          class Client {}                     class FooImpl{}                                ...
Type Coupling                          class Client {}                     class FooImpl{}                                ...
Instance Coupling                  •       New                  •       Factory                  •       Inversion of Cont...
Instance Coupling                                                 client   container   impl                  •       New  ...
Instance Coupling                                                 client   container   impl                  •       New  ...
Instance Coupling                                                 client   container   impl                  •       New  ...
Instance Coupling                                                 client   container   impl                  •       New  ...
Instance Coupling                                                 client   container   impl                  •       New  ...
µServices Primitive                  •       Broker Pattern                  •       Direction                  •       Co...
µServices Primitive                  •       Broker Pattern                  •       Direction                  •       Co...
Patterns                  •       Factory                  •       Listener                  •       Discovery            ...
5. Optimize                               Ewoensdag 16 november 11
5. Optimize                          A    B   C                          D    E   F                          G    H   Iwoe...
Back to the Brick Wallwoensdag 16 november 11
Migration                          A   B   C                          D   E   F                          G   H   Iwoensdag...
Migration                          A   B   C                          D   E   F                          G   H   Iwoensdag...
Migration                          A   B   C                          D   E   F                          G   H   Iwoensdag...
Migration                          A   B   C                          D   E   F                          G   H   Iwoensdag...
Migration                          A   B   C                          D   E   F                          G   H   Iwoensdag...
So we need a broker                           that runs without                                fences...woensdag 16 novemb...
So we need a Broker                           that runs without                                Fences...SR                ...
POJOSR                  • Developed by Karl Pauls                  • JavaOne presentation 24811                  • http://...
Gain                  •       Existing libraries and many bundles work without                          modification       ...
Loss                  •       No dynamic install/uninstall/update                  •       No side-by-side versioning     ...
Migrating                  • Example: extend ant … the tool we all                          (sometimes) love and (sometime...
Ant Your Service                  •       Base ant                  •       Activator                  •       Extender   ...
Ant Your Service                  •       Base ant     pojosr                                        ant                  ...
Ant Your Service                  •       Base ant     pojosr                                        ant                  ...
Ant Your Service                                                 Class<Task>                  •       Base ant     pojosr ...
Ant Your Service                                                 Class<Task>                                              ...
Ant Your Service                                                 Class<Task>                                              ...
Ant Your Service               <project name="master">               	    <path id="bundles">               	    	 <filese...
Ant Your Service               public class Activator implements BundleActivator {               	    public void start(Bu...
Ant Your Service               public class Activator implements BundleActivator {                                        ...
Ant Your Service                                                 Class<Task>                                              ...
Ant Your Service                                                 Class<Task>                                              ...
Ant Your Service                                                 Class<Task>                                              ...
Ant Your Service                public class HelloTask extends Task {                	 String message = "Hello Extender"; ...
Ant Your Service                public class HelloTask extends Task {                	 String message = "Hello Extender"; ...
Conclusion                  • Moving to Fences is hard because popular                          instance creation patterns...
Good Fences                    Make Good Neighborswoensdag 16 november 11
Good Fences                                od ul es                    Make Good Neighbors                              mw...
Q&Awoensdag 16 november 11
Upcoming SlideShare
Loading in...5
×

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

1,565

Published on

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.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,565
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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

  1. 1. Services-First Migration to OSGi BJ Hargrave (IBM) Peter Kriens (aQute)woensdag 16 november 11
  2. 2. Agenda • Modularity Maturity Model • The Brick Wall • Couplings • µServices • What Broker? • Example • Conclusionwoensdag 16 november 11
  3. 3. 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
  4. 4. Modularity Maturity Modelwoensdag 16 november 11
  5. 5. 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
  6. 6. 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
  7. 7. 2. Managed • Treat JARs as a module • JAR Identity • Naming • Versioning • Dependencies • Repositorieswoensdag 16 november 11
  8. 8. 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
  9. 9. 3. Contracts • Interface based design, POJOs • Provide contracts for each connection between JARs • Implementation details inside the JAR • Versioning on contractswoensdag 16 november 11
  10. 10. 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
  11. 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
  12. 12. 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
  13. 13. 5. Optimize • Exploit concepts for modules and contracts • Delegated Control • Optimize the code base to leverage new patterns: • Extender • Whiteboard • Repeatwoensdag 16 november 11
  14. 14. 5. Optimize • Exploit concepts for modules and contracts • Delegated Control • Optimize the code base to leverage new patterns: • Extender • Whiteboard • Repeatwoensdag 16 november 11
  15. 15. Today 1. Ad Hoc 2. 3. Managed Contracts 4. Fences 5. Optimizewoensdag 16 november 11
  16. 16. 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
  17. 17. 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
  18. 18. 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
  19. 19. woensdag 16 november 11
  20. 20. woensdag 16 november 11
  21. 21. Class.forName(String)woensdag 16 november 11
  22. 22. Class Space package classwoensdag 16 november 11
  23. 23. Class Space package classwoensdag 16 november 11
  24. 24. Class Space package classwoensdag 16 november 11
  25. 25. Class Space V1 V2woensdag 16 november 11
  26. 26. Class Space V1 V2woensdag 16 november 11
  27. 27. Class Space V1 V2 Class.forNamewoensdag 16 november 11
  28. 28. Class Space V1 V2 x x Class.forNamewoensdag 16 november 11
  29. 29. Class Space V1 V2 x x Class.forNamewoensdag 16 november 11
  30. 30. Why Class.forName?woensdag 16 november 11
  31. 31. Why Class.forName? ! ! ! ! ! ! ! ! ! ! ! ! N G! P LI C O Uwoensdag 16 november 11
  32. 32. How to get an Instance? That is the Question!woensdag 16 november 11
  33. 33. Couplings modular not Example modular type FooImpl foo; Foo foo = (Foo) instance Class.forName(“FooImpl”) .newInstance();woensdag 16 november 11
  34. 34. Type Coupling class Client {} class FooImpl{}woensdag 16 november 11
  35. 35. Type Coupling class Client {} class FooImpl{}woensdag 16 november 11
  36. 36. Type Coupling class Client {} class FooImpl{} interface Foo{}woensdag 16 november 11
  37. 37. Type Coupling class Client {} class FooImpl{} interface Foo{} uses implementswoensdag 16 november 11
  38. 38. Type Coupling class Client {} class FooImpl{} interface Foo{} uses implements get instancewoensdag 16 november 11
  39. 39. 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
  40. 40. Instance Coupling • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  41. 41. Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  42. 42. Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  43. 43. Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  44. 44. Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  45. 45. Instance Coupling client container impl • New • Factory • Inversion of Control • Brokerwoensdag 16 november 11
  46. 46. µServices Primitive • Broker Pattern • Direction • Contract • Publish • Find • Bind • Who’s Listening? • Cardinalitywoensdag 16 november 11
  47. 47. µServices Primitive • Broker Pattern • Direction • Contract • Publish A S B • Find • Bind • Who’s listening? • Cardinalitywoensdag 16 november 11
  48. 48. Patterns • Factory • Listener • Discovery • Distributionwoensdag 16 november 11
  49. 49. 5. Optimize Ewoensdag 16 november 11
  50. 50. 5. Optimize A B C D E F G H Iwoensdag 16 november 11
  51. 51. Back to the Brick Wallwoensdag 16 november 11
  52. 52. Migration A B C D E F G H Iwoensdag 16 november 11
  53. 53. Migration A B C D E F G H Iwoensdag 16 november 11
  54. 54. Migration A B C D E F G H Iwoensdag 16 november 11
  55. 55. Migration A B C D E F G H Iwoensdag 16 november 11
  56. 56. Migration A B C D E F G H Iwoensdag 16 november 11
  57. 57. So we need a broker that runs without fences...woensdag 16 november 11
  58. 58. So we need a Broker that runs without Fences...SR o j o Pwoensdag 16 november 11
  59. 59. POJOSR • Developed by Karl Pauls • JavaOne presentation 24811 • http://pojosr.googlecode.com • Based on Apache Felixwoensdag 16 november 11
  60. 60. 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
  61. 61. 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
  62. 62. Migrating • Example: extend ant … the tool we all (sometimes) love and (sometimes) hate • We make different <helloXXX/> taskswoensdag 16 november 11
  63. 63. Ant Your Service • Base ant • Activator • Extender ant ... ...woensdag 16 november 11
  64. 64. Ant Your Service • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  65. 65. Ant Your Service • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  66. 66. Ant Your Service Class<Task> • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  67. 67. Ant Your Service Class<Task> hello activator • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  68. 68. Ant Your Service Class<Task> hello activator • Base ant pojosr ant • Activator • Extender ant ... ...woensdag 16 november 11
  69. 69. 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
  70. 70. 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
  71. 71. 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
  72. 72. Ant Your Service Class<Task> hello activator • Base ant pojosr pojo ant • Activator • Extender ant ... ...woensdag 16 november 11
  73. 73. Ant Your Service Class<Task> hello activator • Base ant pojosr pojo ant hello extendee • Activator • Extender ant ... ...woensdag 16 november 11
  74. 74. 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
  75. 75. 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
  76. 76. 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
  77. 77. 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
  78. 78. Good Fences Make Good Neighborswoensdag 16 november 11
  79. 79. Good Fences od ul es Make Good Neighbors mwoensdag 16 november 11
  80. 80. Q&Awoensdag 16 november 11
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×