If you can't read please download the document
Upload
toni-epple
View
10.026
Download
1
Embed Size (px)
Citation preview
Frankenstein's IDE
Anton EppleEppleton IT Consultinghttp://www.eppleton.de
Frankenstein's IDE: Running NetBeans on OSGi and vice versa
Agenda
Module Systems
Service Infrastructure
Project netigso: bringing it all together
Demos
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
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 ... )
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?
Core / Runtime ContainerBasic ServicesApp Bundle 1App Bundle 4App Bundle 5App Bundle 6App Bundle 2App Bundle 3Runtime 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
Module System
How does the NetBeans module system work?
Core / Runtime ContainerBasic ServicesApp Bundle 1App Bundle 4App Bundle 5App Bundle 6App Bundle 2App Bundle 3Runtime 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
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
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
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
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
Module System
Meta-Data:
NetBeansOSGi
Identifier
OpenIDE-Module: XBundle-SymbolicName: X
Version numberOpenIDE-Module-Specification-Version: 7.3Bundle-Version: 7.3
ActivatorOpenIDE-Module-Install: x.y.z.ActivatorBundle-Activator: x.y.z.Activator
Exported PackagesOpenIDE-Module-Public-Packages: x.y.zExport-Package: x.y.z
Imported DependenciesOpenIDE-Module-Module-Dependencies: another.module > 2.1Require-Bundle: another.module;bundle-version="(2.1 )"
Module System
Conclusion:
Great minds think alike
but not always
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)
OSGi
Specific to NetBeans:Tokens for declaring Service Dependencies:Requires
Provides...
Demo LookupSample:
OpenIDE-Module-Requires: de.eppleton.extensionpointinterface.MessageProviderInterfaceOpenIDE-Module-Provides: de.eppleton.extensionpointinterface.MessageProviderInterface
Agenda
Module Systems
Service Infrastructure
Project netigso: bringing it all together
Demos
Service Infrastructure
OSGi: OSGi Services
Dynamic Services
Declarative Services
Eclipse Extension Points
...
Service Infrastructure
NetBeans Platform: LookupRegistration based on Java Standards (JAR Spec & ServiceLoader)
+ Listening for Changes
+ Lazy Loading
+ Ordering
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
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
Service Infrastructure
Comparison OSGi & NetBeans Services:
NB Services very flexible, but not self documented
NetBeansDeclarative ServicesExtension Points
1 Service can contribute to more than one Extension Point++-
No need to implement interface+-+
Metadata for Documentation- ApiDoc++
Agenda
Modular Systems
Service Infrastructure
Project netigso: bringing it all together
Demos
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
Project Netigso
Netigso:Felix OSGi container embedded in NetBeans
Interoperability for NetBeans Modules OSGi bundlesDependency Management over system boundaries
Final target: Make platform interchangeable
http://wiki.netbeans.org/OSGiAndNetBeans
Project Netigso
Netigso:Creates Bundles/Modules in NetBeans (build harness)
Demo
Hello World Demo:Creating a Bundle with Netigso
Project Netigso
Netigso:NB understands both types of metadata: Setting dependencies between Modules and bundles possible
Demo
Interoperability Demo:Creating a Module that uses classes from OSGi bundle
Project Netigso
Service Interoperability:Bundles can contribute to NB Extension points
XML registry & Lookup works
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 activators = new ArrayList(); activators.add(activator); configMap.put("felix.systembundle.activators", activators); felix = new Felix(configMap); felix.init();
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
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(); }...
Agenda
Recap: Modularity
OSGi
Service Infrastructure
Project Netigso
Demo
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
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
Lessons Learned
Lessons learnedOSGi & NB Module system are very similar and interoperable
Problems:Equinox core bundle contains helper classesPackage 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
Demo
Distributed OSGi Hello World Demo:Reference Implementation (Apache CFX)
Status
To run NB on OSGi:We need to implement Lookup & System FileSystem in OSGIBoth systems need to access resources from all bundles
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
Q&A
Click to edit the title text
Click to edit the outline textSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level
NetBeans Day Atlanta 2007
Folientitel
Klicken Sie, um die Formate des Gliederungstextes zu bearbeiten
Zweite Gliederungsebene
Dritte Gliederungsebene
Vierte Gliederungsebene
Fnfte Gliederungsebene
Sechste Gliederungsebene
Siebente Gliederungsebene
Achte Gliederungsebene
Neunte Gliederungsebene
NetBeans Rich Client Platform
Folientitel
Klicken Sie, um die Formate des Gliederungstextes zu bearbeitenZweite GliederungsebeneDritte GliederungsebeneVierte GliederungsebeneFnfte GliederungsebeneSechste GliederungsebeneSiebente GliederungsebeneAchte GliederungsebeneNeunte Gliederungsebene
Source Talk Tage 2008NetBeans Rich Client Platform