Frankenstein's IDE Anton Epple Eppleton IT Consulting http://www.eppleton.de Frankenstein's IDE: Running NetBeans on OSGi ...
Agenda <ul><li>Module Systems
Service Infrastructure
Project netigso: bringing it all together
Demos </li></ul>
Modularity Recap: Why a module system? Standard Java doesn't support: <ul><ul><li>Versioning
Plugins & Updates
Dynamic Service Infrastructure
Dependency management
Controlled API export (information hiding) </li></ul></ul>Module Systems like OSGi & NetBeans Module System add this
Modularity NetBeans Module System? Started in 1996: <ul><ul><li>Foundation of the IDE ( first NetBeans release 1999 )
Usable as independent platform for many years
Used on client & server
Many commercial and institutional users ( Nokia, Boeing, UNESCO, EADS, US Army ... ) </li></ul></ul>
Duke's Choice Award 2009
Duke's Choice Award 2009 What's the difference between OSGi and NB Platform?
Module System How does the OSGi module system work? <ul><li>Runtime Container manages Life cycle and dependencies of modules
Basic Services provide reusable functionality
API/SPI Modules provide Extension Points and Utility Classes
User Modules provide application functionality </li></ul>
Module System How does the NetBeans module system work? <ul><li>Runtime Container manages Life cycle and dependencies of m...
Basic Services provide reusable functionality
API/SPI Modules provide Extension Points and Utility Classes
User Modules provide application functionality </li></ul>
Module System How does the OSGi module system work? <ul><li>Runtime starts up reads meta information and sets up dependenc...
Starts the Modules
ClassLoader:  Every Module has it's own classloader. It can only load classes from other Modules if it has declared a depe...
Module System How does the NetBeans module system work? <ul><li>Runtime starts up reads meta information and sets up depen...
Starts the Modules
ClassLoader:  Every Module has it's own classloader. It can only load classes from other Modules if it has declared a depe...
Tip : Cross-check mailing list for third-party lib problems </li></ul>
Module System How is a OSGi bundle constructed? <ul><li>Module is a JAR Archive containing: </li><ul><li>META-INF/MANIFEST...
Version
Public API
Dependencies </li></ul><li>Service registration </li></ul></ul>
Module System How is a NetBeans module constructed? <ul><li>Module is a JAR Archive containing: </li><ul><li>META-INF/MANI...
Version
Public API
Dependencies </li></ul><li>Service registration </li></ul></ul>
Module System Meta-Data: NetBeans OSGi Identifier OpenIDE-Module: X Bundle-SymbolicName: X Version number OpenIDE-Module-S...
Module System Conclusion: Great minds think alike …  but not always
Upcoming SlideShare
Loading in …5
×

Frankenstein's IDE: NetBeans and OSGi

10,020 views

Published on

Using OSGi Bundles in NetBeans Modules and vice versa

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

No Downloads
Views
Total views
10,020
On SlideShare
0
From Embeds
0
Number of Embeds
2,584
Actions
Shares
0
Downloads
106
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Frankenstein's IDE: NetBeans and OSGi

  1. 1. Frankenstein's IDE Anton Epple Eppleton IT Consulting http://www.eppleton.de Frankenstein's IDE: Running NetBeans on OSGi and vice versa
  2. 2. Agenda <ul><li>Module Systems
  3. 3. Service Infrastructure
  4. 4. Project netigso: bringing it all together
  5. 5. Demos </li></ul>
  6. 6. Modularity Recap: Why a module system? Standard Java doesn't support: <ul><ul><li>Versioning
  7. 7. Plugins & Updates
  8. 8. Dynamic Service Infrastructure
  9. 9. Dependency management
  10. 10. Controlled API export (information hiding) </li></ul></ul>Module Systems like OSGi & NetBeans Module System add this
  11. 11. Modularity NetBeans Module System? Started in 1996: <ul><ul><li>Foundation of the IDE ( first NetBeans release 1999 )
  12. 12. Usable as independent platform for many years
  13. 13. Used on client & server
  14. 14. Many commercial and institutional users ( Nokia, Boeing, UNESCO, EADS, US Army ... ) </li></ul></ul>
  15. 15. Duke's Choice Award 2009
  16. 16. Duke's Choice Award 2009 What's the difference between OSGi and NB Platform?
  17. 17. Module System How does the OSGi module system work? <ul><li>Runtime Container manages Life cycle and dependencies of modules
  18. 18. Basic Services provide reusable functionality
  19. 19. API/SPI Modules provide Extension Points and Utility Classes
  20. 20. User Modules provide application functionality </li></ul>
  21. 21. Module System How does the NetBeans module system work? <ul><li>Runtime Container manages Life cycle and dependencies of modules
  22. 22. Basic Services provide reusable functionality
  23. 23. API/SPI Modules provide Extension Points and Utility Classes
  24. 24. User Modules provide application functionality </li></ul>
  25. 25. Module System How does the OSGi module system work? <ul><li>Runtime starts up reads meta information and sets up dependencies
  26. 26. Starts the Modules
  27. 27. ClassLoader: Every Module has it's own classloader. It can only load classes from other Modules if it has declared a dependency. Loading is then delegated to the other modules ClassLoader </li></ul>
  28. 28. Module System How does the NetBeans module system work? <ul><li>Runtime starts up reads meta information and sets up dependencies
  29. 29. Starts the Modules
  30. 30. ClassLoader: Every Module has it's own classloader. It can only load classes from other Modules if it has declared a dependency. Loading is then delegated to the other modules ClassLoader
  31. 31. Tip : Cross-check mailing list for third-party lib problems </li></ul>
  32. 32. Module System How is a OSGi bundle constructed? <ul><li>Module is a JAR Archive containing: </li><ul><li>META-INF/MANIFEST.MF </li><ul><li>Id
  33. 33. Version
  34. 34. Public API
  35. 35. Dependencies </li></ul><li>Service registration </li></ul></ul>
  36. 36. Module System How is a NetBeans module constructed? <ul><li>Module is a JAR Archive containing: </li><ul><li>META-INF/MANIFEST.MF </li><ul><li>Id
  37. 37. Version
  38. 38. Public API
  39. 39. Dependencies </li></ul><li>Service registration </li></ul></ul>
  40. 40. Module System Meta-Data: NetBeans OSGi Identifier OpenIDE-Module: X Bundle-SymbolicName: X Version number OpenIDE-Module-Specification-Version: 7.3 Bundle-Version: 7.3 Activator OpenIDE-Module-Install: x.y.z.Activator Bundle-Activator: x.y.z.Activator Exported Packages OpenIDE-Module-Public-Packages: x.y.z Export-Package: x.y.z Imported Dependencies OpenIDE-Module-Module-Dependencies: another.module > 2.1 Require-Bundle: another.module;bundle-version=&quot;(2.1 )&quot;
  41. 41. Module System Conclusion: Great minds think alike … but not always
  42. 42. OSGi Specific to OSGi / Equinox: <ul><li>Bundles have different states: </li><ul><li>Installed
  43. 43. Resolved
  44. 44. Started </li></ul><li>Eclipse: Buddy Policies ( dependent, global, app, ext, boot, registered = allow circular classloading dependencies for third party libs) </li></ul>
  45. 45. OSGi Specific to NetBeans: <ul><ul><li>Tokens for declaring Service Dependencies: </li><ul><li>Requires
  46. 46. Provides... </li></ul><li>Demo LookupSample: </li></ul></ul>OpenIDE-Module-Requires: de.eppleton.extensionpointinterface.MessageProviderInterface OpenIDE-Module-Provides: de.eppleton.extensionpointinterface.MessageProviderInterface
  47. 47. Agenda <ul><li>Module Systems
  48. 48. Service Infrastructure
  49. 49. Project netigso: bringing it all together
  50. 50. Demos </li></ul>
  51. 51. Service Infrastructure <ul><li>OSGi: </li><ul><li>OSGi Services
  52. 52. Dynamic Services
  53. 53. Declarative Services
  54. 54. Eclipse Extension Points
  55. 55. ... </li></ul></ul>
  56. 56. Service Infrastructure NetBeans Platform : <ul><ul><li>Lookup </li><ul><li>Registration based on Java Standards (JAR Spec & ServiceLoader)
  57. 57. + Listening for Changes
  58. 58. + Lazy Loading
  59. 59. + Ordering </li></ul></ul></ul>
  60. 60. Service Infrastructure NetBeans Platform : <ul><ul><li>Registry (System FileSystem) </li><ul><li>Per module XML file
  61. 61. Extension points are folders in the FileSystem
  62. 62. Extensions are virtual files in the FileSystem
  63. 63. Files can represent resources or instances
  64. 64. Parametrized instantiation, Factory classes & methods </li></ul><li>Lookups + SFS = NetBeans Service Infrastructure </li></ul></ul>
  65. 65. Service Infrastructure NetBeans Extension Points : <ul><ul><li>Extensions are declarations
  66. 66. One extension can contribute to an indefinite number of Extension points
  67. 67. Extension point definer queries registry when needed ( lazy loading )
  68. 68. Extensions need not be associated with executable Java code </li></ul></ul>
  69. 69. Service Infrastructure <ul><li>Comparison OSGi & NetBeans Services: </li></ul><ul><li>-> NB Services very flexible, but not self documented </li></ul>NetBeans Declarative Services Extension Points 1 Service can contribute to more than one Extension Point + + - No need to implement interface + - + Metadata for Documentation - ApiDoc + +
  70. 70. Agenda <ul><li>Modular Systems
  71. 71. Service Infrastructure
  72. 72. Project netigso: bringing it all together
  73. 73. Demos </li></ul>
  74. 74. Motivation Why would I want an additional Module System? <ul><li>Use the same bundles on client and server
  75. 75. OSGi 4.2 Distributed OSGi: Use the same code to work with local and remote services </li></ul>
  76. 76. Project Netigso Netigso: <ul><li>Felix OSGi container embedded in NetBeans </li></ul><ul><li>Interoperability for NetBeans Modules ↔ OSGi bundles </li><ul><li>Dependency Management over system boundaries </li></ul><li>Final target: Make platform interchangeable
  77. 77. http://wiki.netbeans.org/OSGiAndNetBeans </li></ul>
  78. 78. Project Netigso Netigso: <ul><li>Creates Bundles/Modules in NetBeans (build harness) </li></ul>
  79. 79. Demo Hello World Demo: <ul><li>Creating a Bundle with Netigso </li></ul>
  80. 80. Project Netigso Netigso: <ul><li>NB understands both types of metadata: Setting dependencies between Modules and bundles possible </li></ul>
  81. 81. Demo Interoperability Demo: <ul><li>Creating a Module that uses classes from OSGi bundle </li></ul>
  82. 82. Project Netigso Service Interoperability: <ul><li>Bundles can contribute to NB Extension points
  83. 83. XML registry & Lookup works </li></ul>
  84. 84. Project Netigso Runtime: When a bundle is available, launch embedded felix: configMap.put(&quot;felix.cache.profiledir&quot;, cache); configMap.put(&quot;felix.cache.dir&quot;, cache); configMap.put(Constants.FRAMEWORK_STORAGE, cache); activator = new NetigsoActivator(); // listen to changes List<BundleActivator> activators = new ArrayList<BundleActivator>(); activators.add(activator); configMap.put(&quot;felix.systembundle.activators&quot;, activators); felix = new Felix(configMap); felix.init();
  85. 85. Project Netigso Expose all Modules as bundles to felix: private static final InputStream fakeBundle(Module m) throws IOException { // create in memory jar containing manifest for OSGi container ByteArrayOutputStream os = new ByteArrayOutputStream(); Manifest man = new Manifest(); man.getMainAttributes().putValue(&quot;Manifest-Version&quot;, &quot;1.0&quot;); man.getMainAttributes().putValue(&quot;Bundle-ManifestVersion&quot;, &quot;2&quot;); .... JarOutputStream jos = new JarOutputStream(os, man); jos.close(); return new ByteArrayInputStream(os.toByteArray()); } // later inject the Module ClassLoader into the Bundle
  86. 86. Project Netigso Expose all Bundles as Modules to Module system: final class NetigsoModule extends Module { final Bundle bundle; private NetigsoLoader loader; ... @Override public String getCodeName() { return bundle.getSymbolicName(); } @Override public String getCodeNameBase() { return bundle.getSymbolicName(); } ...
  87. 87. Agenda <ul><li>Recap: Modularity
  88. 88. OSGi
  89. 89. Service Infrastructure
  90. 90. Project Netigso
  91. 91. Demo </li></ul>
  92. 92. Demo Importing Bundles Demo: <ul><li>ant -f $NETIGSO/harness/suite.xml clusterize -Dcluster=plugins -Dincludes=modules/**
  93. 93. Example: Felix Remote Shell
  94. 94. Diagnosis and Management Tool
  95. 95. telnet localhost 6666
  96. 96. Installing and uninstalling bundles </li></ul>
  97. 97. Demo Eclipse Equinox Bundles Demo: <ul><li>Peter Kriens SUDOKU example:
  98. 98. HTTPService serves SUDOKU game
  99. 99. RPC Layer for communication between JavaScript frontend and server
  100. 100. Based on Eclipse Equinox
  101. 101. In Suite add to project.properties: run.args.extra=--nosplash -J-Dorg.osgi.service.http.port=8080 </li></ul>
  102. 102. Lessons Learned Lessons learned <ul><li>OSGi & NB Module system are very similar and interoperable
  103. 103. Problems: </li><ul><li>Equinox core bundle contains helper classes </li><ul><li>Package import vs required bundles </li></ul><li>Services are standardized, but versioning isn't: </li><ul><li>Two bundles implementing the same service can have totally independent version numbers in different OSGi containers => Service implementations not easily interchangeable </li></ul></ul></ul>
  104. 104. Demo Distributed OSGi Hello World Demo: <ul><ul><li>Reference Implementation (Apache CFX) </li></ul></ul>
  105. 105. Status To run NB on OSGi: <ul><li>We need to implement Lookup & System FileSystem in OSGI </li><ul><li>Both systems need to access resources from all bundles </li></ul></ul>
  106. 106. Status Netigso is in early alpha state: <ul><li>Netigso is actively developed
  107. 107. Modules and Bundles can communicate & depend on each other
  108. 108. Standard services are running without problems (J1)
  109. 109. Advanced Examples run in NetBeans
  110. 110. My next project: Running Glassfish
  111. 111. Blog: http://eppleton.sharedhost.de/blog </li></ul>
  112. 112. Q&A

×