Frankenstein's IDE: NetBeans and OSGi

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Group

    Frankenstein's IDE: NetBeans and OSGi - Presentation Transcript

    1. Frankenstein's IDE Anton Epple Eppleton IT Consulting http://www.eppleton.de Frankenstein's IDE: Running NetBeans on OSGi and vice versa
    2. Agenda
      • Module Systems
      • Service Infrastructure
      • Project netigso: bringing it all together
      • Demos
    3. Modularity Recap: Why a module system? Standard Java doesn't support:
        • Versioning
        • Plugins & Updates
        • Dynamic Service Infrastructure
        • Dependency management
        • Controlled API export (information hiding)
      Module Systems like OSGi & NetBeans Module System add this
    4. Modularity NetBeans Module System? Started in 1996:
        • 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 ... )
    5. Duke's Choice Award 2009
    6. Duke's Choice Award 2009 What's the difference between OSGi and NB Platform?
    7. Module System How does the OSGi module system work?
      • 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
    8. Module System How does the NetBeans module system work?
      • 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
    9. Module System How does the OSGi module system work?
      • Runtime starts up reads meta information and sets up dependencies
      • Starts the Modules
      • 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
    10. Module System How does the NetBeans module system work?
      • Runtime starts up reads meta information and sets up dependencies
      • Starts the Modules
      • 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
      • Tip : Cross-check mailing list for third-party lib problems
    11. Module System How is a OSGi bundle constructed?
      • Module is a JAR Archive containing:
        • META-INF/MANIFEST.MF
          • Id
          • Version
          • Public API
          • Dependencies
        • Service registration
    12. Module System How is a NetBeans module constructed?
      • Module is a JAR Archive containing:
        • META-INF/MANIFEST.MF
          • Id
          • Version
          • Public API
          • Dependencies
        • Service registration
    13. 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="(2.1 )"
    14. Module System Conclusion: Great minds think alike … but not always
    15. OSGi Specific to OSGi / Equinox:
      • Bundles have different states:
        • Installed
        • Resolved
        • Started
      • Eclipse: Buddy Policies ( dependent, global, app, ext, boot, registered = allow circular classloading dependencies for third party libs)
    16. OSGi Specific to NetBeans:
        • Tokens for declaring Service Dependencies:
          • Requires
          • Provides...
        • Demo LookupSample:
      OpenIDE-Module-Requires: de.eppleton.extensionpointinterface.MessageProviderInterface OpenIDE-Module-Provides: de.eppleton.extensionpointinterface.MessageProviderInterface
    17. Agenda
      • Module Systems
      • Service Infrastructure
      • Project netigso: bringing it all together
      • Demos
    18. Service Infrastructure
      • OSGi:
        • OSGi Services
        • Dynamic Services
        • Declarative Services
        • Eclipse Extension Points
        • ...
    19. Service Infrastructure NetBeans Platform :
        • Lookup
          • Registration based on Java Standards (JAR Spec & ServiceLoader)
          • + Listening for Changes
          • + Lazy Loading
          • + Ordering
    20. Service Infrastructure NetBeans Platform :
        • Registry (System FileSystem)
          • Per module XML file
          • Extension points are folders in the FileSystem
          • Extensions are virtual files in the FileSystem
          • Files can represent resources or instances
          • Parametrized instantiation, Factory classes & methods
        • Lookups + SFS = NetBeans Service Infrastructure
    21. Service Infrastructure NetBeans Extension Points :
        • Extensions are declarations
        • One extension can contribute to an indefinite number of Extension points
        • Extension point definer queries registry when needed ( lazy loading )
        • Extensions need not be associated with executable Java code
    22. Service Infrastructure
      • Comparison OSGi & NetBeans Services:
      • -> NB Services very flexible, but not self documented
      NetBeans Declarative Services Extension Points 1 Service can contribute to more than one Extension Point + + - No need to implement interface + - + Metadata for Documentation - ApiDoc + +
    23. Agenda
      • Modular Systems
      • Service Infrastructure
      • Project netigso: bringing it all together
      • Demos
    24. Motivation Why would I want an additional Module System?
      • Use the same bundles on client and server
      • OSGi 4.2 Distributed OSGi: Use the same code to work with local and remote services
    25. Project Netigso Netigso:
      • Felix OSGi container embedded in NetBeans
      • Interoperability for NetBeans Modules ↔ OSGi bundles
        • Dependency Management over system boundaries
      • Final target: Make platform interchangeable
      • http://wiki.netbeans.org/OSGiAndNetBeans
    26. Project Netigso Netigso:
      • Creates Bundles/Modules in NetBeans (build harness)
    27. Demo Hello World Demo:
      • Creating a Bundle with Netigso
    28. Project Netigso Netigso:
      • NB understands both types of metadata: Setting dependencies between Modules and bundles possible
    29. Demo Interoperability Demo:
      • Creating a Module that uses classes from OSGi bundle
    30. Project Netigso Service Interoperability:
      • Bundles can contribute to NB Extension points
      • XML registry & Lookup works
    31. 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();
    32. 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
    33. 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(); } ...
    34. Agenda
      • Recap: Modularity
      • OSGi
      • Service Infrastructure
      • Project Netigso
      • Demo
    35. Demo Importing Bundles Demo:
      • ant -f $NETIGSO/harness/suite.xml clusterize -Dcluster=plugins -Dincludes=modules/**
      • Example: Felix Remote Shell
      • Diagnosis and Management Tool
      • telnet localhost 6666
      • Installing and uninstalling bundles
    36. Demo Eclipse Equinox Bundles Demo:
      • Peter Kriens SUDOKU example:
      • HTTPService serves SUDOKU game
      • RPC Layer for communication between JavaScript frontend and server
      • Based on Eclipse Equinox
      • In Suite add to project.properties: run.args.extra=--nosplash -J-Dorg.osgi.service.http.port=8080
    37. Lessons Learned Lessons learned
      • OSGi & NB Module system are very similar and interoperable
      • Problems:
        • Equinox core bundle contains helper classes
          • Package import vs required bundles
        • Services are standardized, but versioning isn't:
          • Two bundles implementing the same service can have totally independent version numbers in different OSGi containers => Service implementations not easily interchangeable
    38. Demo Distributed OSGi Hello World Demo:
        • Reference Implementation (Apache CFX)
    39. Status To run NB on OSGi:
      • We need to implement Lookup & System FileSystem in OSGI
        • Both systems need to access resources from all bundles
    40. Status Netigso is in early alpha state:
      • Netigso is actively developed
      • Modules and Bundles can communicate & depend on each other
      • Standard services are running without problems (J1)
      • Advanced Examples run in NetBeans
      • My next project: Running Glassfish
      • Blog: http://eppleton.sharedhost.de/blog
    41. Q&A

    + Toni EppleToni Epple, 6 months ago

    custom

    1640 views, 0 favs, 1 embeds more stats

    Using OSGi Bundles in NetBeans Modules and vice ver more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1640
      • 1568 on SlideShare
      • 72 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 28
    Most viewed embeds
    • 72 views on http://eppleton.sharedhost.de

    more

    All embeds
    • 72 views on http://eppleton.sharedhost.de

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events