This document summarizes a presentation on bringing together the NetBeans module system and OSGi module system. It discusses how both systems use modules and services, and describes a project called Netigso that allows NetBeans modules to interact with OSGi bundles and vice versa. It provides demos of creating modules and bundles that can depend on each other across the two systems. The goal is to make the NetBeans platform interchangeable with OSGi.
1 of 41
More Related Content
Frankenstein's IDE: NetBeans and OSGi
1. Frankenstein's IDE Anton Epple Eppleton IT Consulting http://www.eppleton.de Frankenstein's IDE: Running NetBeans on OSGi and vice versa
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
28. Module System How does the NetBeans module system work? Runtime starts up reads meta information and sets up dependencies
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
69. 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 + +
74. Motivation Why would I want an additional Module System? Use the same bundles on client and server
75. OSGi 4.2 Distributed OSGi: Use the same code to work with local and remote services
76. 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
84. Project Netigso Runtime: When a bundle is available, launch embedded felix: configMap.put("felix.cache.profiledir", cache); configMap.put("felix.cache.dir", cache); configMap.put(Constants.FRAMEWORK_STORAGE, cache); activator = new NetigsoActivator(); // listen to changes List<BundleActivator> activators = new ArrayList<BundleActivator>(); activators.add(activator); configMap.put("felix.systembundle.activators", activators); felix = new Felix(configMap); felix.init();
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("Manifest-Version", "1.0"); man.getMainAttributes().putValue("Bundle-ManifestVersion", "2"); .... JarOutputStream jos = new JarOutputStream(os, man); jos.close(); return new ByteArrayInputStream(os.toByteArray()); } // later inject the Module ClassLoader into the Bundle
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(); } ...
103. 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