Multi-Bundle                      Scoping in                        OSGi                                Glyn Normington   ...
Agenda•Modules in Java• Multi-bundle modules• Scoping mechanisms• Subsystems
Modules in Java
Modularitythe degree to which a system’s componentsmay be separated and recombinedthe tightness of coupling between compon...
Modularitythe degree to which a system’s componentsinformationmay be separated and recombinedthe tightness of coupling bet...
Modules in Java• Class• Package• JAR• Class loader      }   OSGi bundle• Module - Java 8• Larger scale modules?
Multi-Bundle Modules
Information to Hide• Bundle• Package• Generic capability• Service
Example 1Feature bundle       bundle bundle       bundle
Example 2Scoped App  bundle       bundle  bundle       bundle
Example 3Kernelbundle       bundlebundle       bundle
Scoping Mechanisms
Scoping Mechanisms• x-internal/x-friends• metadata rewriting• composite bundle• framework hooks• region digraph
Eclipse x-* Directives• Export-Package directives• Enforced by framework•   x-internal•   x-friends• Non-standard• Naming ...
Metadata RewritingHide internals:   • Decorate referents    • Bundles and packages    • Generic capabilities   • Fix refer...
Metadata Rewriting     in Virgo     Demo ...
Metadata RewritingIssues:• Suitable for isolated applications only• Intrusive• Complicates bundle update• Can be coded rou...
Composite Bundle• OSGi draft spec• Prototyped in Equinox, deprecated• Uses framework instance• Surrogate bundle represents...
Composite BundleIssues:• Implemented in the framework• Cannot expose constituent bundles• Hard to spec portably➡ Superseded
Framework Hooks• Part of OSGi 4.3 core• Control visibility• Enable framework to be partitioned• 5 main hooks: • resolver h...
Framework HooksIssues:• Low level• Consistency of hooks• Coexistence of sets of hooks➡ Higher level API needed
Region Digraph
Graph Theory Interlude
Tree
DAG
Digraph
Graph
Region Digraph•   Framework hook abstraction•   Bundles partitioned into regions•   Regions connected by filters    •   Bun...
Example Digraph    region A       p3            "allow p1"      p1, p2    region B
Example Digraph    region A                         visible: p1, p3       p3            "allow p1"      p1, p2            ...
Example Digraph 2region X      "allow p1, p3"  p1, p2          "allow p3, p4"     p3, p4region Y                          ...
Example Digraph 2      region X                         visible: p1, p3             "allow p1, p3"         p1, p2         ...
Region Digraph• Equinox bundle• Runs on standard framework hooks• Persistent• JMX
Region Digraph Uses                                                     user region• Virgo 3.0 kernel/user region         ...
Region Digraph in Virgo       Demo ...
Region Digraph APIpublic interface RegionDigraph ... {	 Region createRegion(String regionName) throws BundleException;    ...
Region DigraphIssues:• Too low level for application use• Non-standard➡ Standard, high-level programming model
Subsystems
Why Subsystems?5 projects have multi-bundle constructs• Poor portability• Inconsistent terminology• Diverse function➡ Stan...
Subsystems• OSGi Enterprise Expert Group• Scoping based on composite bundles  framework hooks• Public draft available (“RF...
What is a Subsystem?• Group of constituents with dependencies • Constituents: bundles, subsystems, ... • Dependencies: loo...
Subsystem ScopingSubsystem type     Scoping   application   contents hidden   composite      configurable    feature       ...
Example 1 Application  Feature
Example 2 Feature A Feature C Feature B
Example 3Application AApplication BComposite C
Scoping and RegionsSubsystem scoping can be• defined in terms of• implemented usinga region digraph
Complex Scoping 1  App3         FeatureQ         FeatureR         FeatureP     CompositeC
Region Digraph         Region A3     App3   FeatureQ              FeatureR              FeatureP                          ...
Complex Scoping 2        Root    Application A    Application B    Composite C    Composite D    Application E
Region Digraph         RootApp A   Comp D   App E                             Root                         Application A  ...
Dependencies        FeatureXApp1                App2        FeatureY       CompositeF
Installing Dependencies                    Root  "accepttransitive"                 CompositeF          App1              ...
Installing Dependencies                  Root  "accepttransitive"               CompositeFApp1          App2   FeatureX   ...
Region DigraphRegion    Region F     Region A1                     A2          FeatureXApp1                   App2        ...
ConclusionModularity in Java:• Class, package, JAR, class loader• Modules in Java 8• Larger modules?Modularity in OSGi:• B...
Further Information•   Public draft of subsystems (RFC 152)    •   http://www.osgi.org/Download/File?url=/download/osgi-ea...
Thanks to...• Wikipedia image courtesy of Wikipedia.org• Field of Flowers by Paul Podsiadlo and Elena  Shevchenko, courtes...
Upcoming SlideShare
Loading in …5
×

Conole vilnius 3_nov

1,377 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
1,377
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Conole vilnius 3_nov

    1. 1. Multi-Bundle Scoping in OSGi Glyn Normington 50 µm lead sulphide assemblies each containing ~108 nanoparticlesCopyright VMware Inc. 2011. Licensed under the Eclipse Public License
    2. 2. Agenda•Modules in Java• Multi-bundle modules• Scoping mechanisms• Subsystems
    3. 3. Modules in Java
    4. 4. Modularitythe degree to which a system’s componentsmay be separated and recombinedthe tightness of coupling between componentsthe degree to which the system architecturecontrols the mixing and matching of components
    5. 5. Modularitythe degree to which a system’s componentsinformationmay be separated and recombinedthe tightness of coupling between componentsthe degree to which the system architecture hidingcontrols the mixing and matching of components
    6. 6. Modules in Java• Class• Package• JAR• Class loader } OSGi bundle• Module - Java 8• Larger scale modules?
    7. 7. Multi-Bundle Modules
    8. 8. Information to Hide• Bundle• Package• Generic capability• Service
    9. 9. Example 1Feature bundle bundle bundle bundle
    10. 10. Example 2Scoped App bundle bundle bundle bundle
    11. 11. Example 3Kernelbundle bundlebundle bundle
    12. 12. Scoping Mechanisms
    13. 13. Scoping Mechanisms• x-internal/x-friends• metadata rewriting• composite bundle• framework hooks• region digraph
    14. 14. Eclipse x-* Directives• Export-Package directives• Enforced by framework• x-internal• x-friends• Non-standard• Naming friends is brittle➡ Standard, maintainable mechanism
    15. 15. Metadata RewritingHide internals: • Decorate referents • Bundles and packages • Generic capabilities • Fix references • Use service registry hooks
    16. 16. Metadata Rewriting in Virgo Demo ...
    17. 17. Metadata RewritingIssues:• Suitable for isolated applications only• Intrusive• Complicates bundle update• Can be coded round• Non-standard➡ Standard scoping in the framework
    18. 18. 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
    19. 19. Composite BundleIssues:• Implemented in the framework• Cannot expose constituent bundles• Hard to spec portably➡ Superseded
    20. 20. 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
    21. 21. Framework HooksIssues:• Low level• Consistency of hooks• Coexistence of sets of hooks➡ Higher level API needed
    22. 22. Region Digraph
    23. 23. Graph Theory Interlude
    24. 24. Tree
    25. 25. DAG
    26. 26. Digraph
    27. 27. Graph
    28. 28. Region Digraph• Framework hook abstraction• Bundles partitioned into regions• Regions connected by filters • Bundles • Packages • Generic capabilities • Services
    29. 29. Example Digraph region A p3 "allow p1" p1, p2 region B
    30. 30. Example Digraph region A visible: p1, p3 p3 "allow p1" p1, p2 visible: p1, p2 region B
    31. 31. Example Digraph 2region X "allow p1, p3" p1, p2 "allow p3, p4" p3, p4region Y region Z
    32. 32. Example Digraph 2 region X visible: p1, p3 "allow p1, p3" p1, p2 "allow p3, p4" p3, p4 region Y region Zvisible: p1, p2, p3, p4
    33. 33. Region Digraph• Equinox bundle• Runs on standard framework hooks• Persistent• JMX
    34. 34. Region Digraph Uses user region• Virgo 3.0 kernel/user region p3 s3, s4 b3• Apache Aries “subsystems” "allow s3" "allow p1, s1, b1" prototype (service of p1 type)• Standalone: p1, p2 s1, s2 b1, b2 “Were using [the region digraph] kernel essentially for a fully multi-tenant plugin system to Web applications.” Robert Sauer
    35. 35. Region Digraph in Virgo Demo ...
    36. 36. Region Digraph APIpublic interface RegionDigraph ... { Region createRegion(String regionName) throws BundleException; RegionFilterBuilder createRegionFilterBuilder(); ...}public interface Region { void connectRegion(Region headRegion, RegionFilter filter) throws BundleException; ...}
    37. 37. Region DigraphIssues:• Too low level for application use• Non-standard➡ Standard, high-level programming model
    38. 38. Subsystems
    39. 39. Why Subsystems?5 projects have multi-bundle constructs• Poor portability• Inconsistent terminology• Diverse function➡ Standard
    40. 40. Subsystems• OSGi Enterprise Expert Group• Scoping based on composite bundles framework hooks• Public draft available (“RFC 152”)
    41. 41. What is a Subsystem?• Group of constituents with dependencies • Constituents: bundles, subsystems, ... • Dependencies: loosely coupled pre-reqs• Named and versioned• Defined lifecycle
    42. 42. Subsystem ScopingSubsystem type Scoping application contents hidden composite configurable feature none
    43. 43. Example 1 Application Feature
    44. 44. Example 2 Feature A Feature C Feature B
    45. 45. Example 3Application AApplication BComposite C
    46. 46. Scoping and RegionsSubsystem scoping can be• defined in terms of• implemented usinga region digraph
    47. 47. Complex Scoping 1 App3 FeatureQ FeatureR FeatureP CompositeC
    48. 48. Region Digraph Region A3 App3 FeatureQ FeatureR FeatureP App3 FeatureQ FeatureRRegion C CompositeC FeatureP CompositeC
    49. 49. Complex Scoping 2 Root Application A Application B Composite C Composite D Application E
    50. 50. Region Digraph RootApp A Comp D App E Root Application A Application BApp V Comp C Composite C Composite D Application E
    51. 51. Dependencies FeatureXApp1 App2 FeatureY CompositeF
    52. 52. Installing Dependencies Root "accepttransitive" CompositeF App1 App2
    53. 53. Installing Dependencies Root "accepttransitive" CompositeFApp1 App2 FeatureX FeatureY
    54. 54. Region DigraphRegion Region F Region A1 A2 FeatureXApp1 App2 FeatureY CompositeF FeatureX App1 App2 FeatureY CompositeF
    55. 55. ConclusionModularity in Java:• Class, package, JAR, class loader• Modules in Java 8• Larger modules?Modularity in OSGi:• Bundles• Multi-bundle modules• Subsystems
    56. 56. 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
    57. 57. Thanks to...• Wikipedia image courtesy of Wikipedia.org• Field of Flowers by Paul Podsiadlo and Elena Shevchenko, courtesy of Argonne National Laboratory

    ×