OSGi and Equinox explained

Martin Lippert, akquinet agile GmbH [email protected]

© 2007 by Martin Lippert; made available under the EPL v1.0 | April 30, 2007 | A Few Words about Myself…

ƒ Martin Lippert ƒ Senior IT consultant at akquinet agile GmbH, Germany ƒ [email protected]

ƒ Focus ƒ Agile software development ƒ Refactoring ƒ Eclipse technology

ƒ Equinox incubator committer

2 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Overview

ƒ An OSGi Overview ƒ Eclipse Equinox ƒ Use Cases and Examples ƒ More Cool Things using Equinox

3 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 OSG – What?

ƒ OSGi™: ƒ „A dynamic module system for Java“

4 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 OSGi is …

ƒ … a module system for Java that allows the definition of … ƒ Modules (called „bundles“), ƒ Visibility of the bundle contents (public-API vs. private-API) ƒ Dependencies between modules ƒ Versions of modules

5 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 OSGi is …

ƒ … dynamic ƒ Bundles can be installed, started, stopped, uninstalled and updated at runtime

6 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 OSGi is …

ƒ … service oriented ƒ Bundles can publish services (dynamically) ƒ Bundles can find and bind to services through a service registry ƒ The runtime allows services to appear and disappear at runtime

7 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 What does OSGi look like? (Low Level)

Identification Bundle-SymbolicName: org.eclipse..registry Bundle-Version: 3.2.100.v20060918 Bundle-Name: Eclipse Extension Registry Bundle-Vendor: Eclipse.org Classpath Bundle-ClassPath: ., someOtherJar.jar

Lifecycle Bundle-Activator: org.eclipse.core.internal.registry..Activator Dependencies Import-Package: javax.xml.parsers, org.xml.sax, org.osgi.framework;version=1.3 Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.2.0,4.0.0)" Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,J2SE-1.3 Exports Export-Package: org.eclipse.equinox.registry

8 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license OSGi, Eclipse and Equinox

ƒ OSGi Alliance ƒ Produces open specifications for runtime environments ƒ Traditional focus on embedded (home gateway, telematics, …) ƒ Broadening scope – Mobile devices, desktops, enterprise and servers ƒ Several open source implementations including Equinox ƒ Eclipse ƒ Eclipse 3.0 saw the rise of Eclipse the Rich Client Platform (RCP) ƒ Needed a standard, open, flexible, dynamic, modular runtime to replace the home- grown Eclipse runtime ƒ Eclipse has been OSGi-based since 3.0 (3 years, 3 releases) ƒ Equinox ƒ Eclipse OSGi implementation ƒ OSGi R4.0 and R4.1 reference implementation ƒ Consistent component story across computing environments/domains

9 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Implementations

ƒ Open source implementations ƒ Eclipse Equinox (http://www.eclipse.org/equinox/) ƒ (http://cwiki.apache.org/FELIX/index.html) ƒ Knopflerfish (http://www.knopflerfish.org/) ƒ ProSyst mBedded Server Equinox Edition (http://www.prosyst.com/products/osgi_se_equi_ed.html)

ƒ Commercial implementations ƒ ProSyst (http://www.prosyst.com/) ƒ Knopflerfish Pro (http://www.gatespacetelematics.com/)

(not necessarily complete)

10 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Equinox adds More…

ƒ The Equinox projects is more than just an OSGi R4.1 implementation ƒ Adds the Eclipse Extension Point mechanism

ƒ Incubator work in different areas ƒ AOP ƒ Server-side OSGi (graduated) ƒ Management ƒ Provisioning ƒ …

11 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Extension Registry

ƒ Build-in extensibility support ƒ Allows the definition of extension-points and extensions ƒ Some kind of minimal component model (how do bundles interact aside of API calls and class reuse)

ƒ Widely known for the Eclipse SDK ƒ Adding views, editors, etc. to the workbench ƒ But a very powerful mechanism for a wide range of extensions ƒ Self-build extension points for all possible areas of an application ƒ Very flexible system architectures

12 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Where is OSGi & Equinox used?

13 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 The Most Famous Use Case

ƒ Plugging into the Eclipse SDK

14 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Range of Use

ƒ Eclipse (i.e., Equinox) as a modular runtime ƒ Consistent programming model: embedded to server ƒ Reuse components across the spectrum ƒ Some examples…

NASA JPMorgan Lotus Jazz Rational Suite WAS eRCP SAS Borland BEA Swiss Rail BEA Jazz Sprint Daimler Jazz Spring

Embedded Rich Client Tooling Server

15 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Eclipse and Open Source Projects

ƒ Eclipse ƒ Equinox ƒ Rich Ajax Platform ƒ Rich Server Platform – UI ƒ Communications Framework ƒ Corona ƒ Enterprise Component Project ƒ Apache ƒ Felix ƒ Directory ƒ Cocoon ƒ James ƒ Geronimo ƒ Spring community integrating with OSGi

16 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license OSGi as a Server Platform

ƒ Modular ƒ Dynamic ƒ Small ƒ Fast ƒ Flexible

Ideal Server Platform

17 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license WebSphere and BEA

ƒ WAS 6.1 is based on Equinox ƒ BEA’s micro kernel architecture based on Equinox

18 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Adobe Version Cue

ƒ Embedded client/server document management system ƒ Project management functionality for small workgroups ƒ version control, file collaboration, streamlined reviews ƒ Eclipse offers ƒ Multi-platform support ƒ Strong, dynamic, standard component model (Equinox/OSGi) ƒ Configuration management ƒ Reuse components on clients and servers

19 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license IBM Rational Jazz Platform

ƒ Team Collaboration platform ƒ Eclipse/Equinox on Client and Server ƒ Server serves ƒ Traditional content ƒ Dynamic, modular Dojo/Ajax ƒ Web Services with DB2 etc backends ƒ Same programming model on client and server ƒ Run same components on client and server

20 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Server-side Variations

ƒ Traditional App Server ƒ Equinox nested in an App Server ƒ Raw Equinox ƒ Equinox nested in another Equinox ƒ App Server on Equinox

21 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Traditional Server Example

ƒ Server function (e.g., servlets) packaged in a WAR ƒ Application Install/Update/Manage whole WARs ƒ Application isolation ƒ No OSGi

WAR … WAR JSP Servlet … Servlet JSP …

App Server OS

22 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Equinox in an App Server ƒ Bridge servlet hosts Equinox in traditional App Server ƒ Application isolation ƒ Integration with existing infrastructure ƒ Forwarding (Lite) HTTP Service ƒ Expose underlying App Server capabilities ƒ Add application function as bundles or servlets or JSPs, … ƒ Install/Update/Manage “WAR” by managing bundles Servlet JSP Servlet Servlet

Bundle HTTP Lite … Web Bundle HTTP Lite … Web

Equinox Equinox Equinox WAR … Equinox WAR Not to scale Bridge Servlet Bridge Servlet NotBridge to scale is tiny Bridge is tiny App Server OS

23 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Raw Equinox ƒ Run Equinox directly ƒ Process isolation ƒ HTTP Service (e.g., embedded bundle) ƒ Add application function as bundles, servlets, JSPs, AJAX, … ƒ Install/Update/Manage server by managing bundles ƒ Web Services

JSP Servlet JSP Servlet Bundle Jetty … Web Bundle Jetty … Web Equinox … Equinox OS

24 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Equinox nested in Equinox ƒ Run Equinox directly, nest other Equinox instances ƒ Nested framework isolation ƒ HTTP Service (e.g., embedded Jetty bundle) ƒ Add server function as bundles, servlets, JSPs, AJAX, … ƒ Install/Update/Manage server by managing bundles ƒ Web Services, …

JSP Servlet … … Servlet JSP Bundle Jetty Web Bundle Bundle Web

Bundle Jetty … Web Equinox … Equinox Equinox OS

25 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license App Server on Equinox

ƒ Add App Server function as bundles ƒ For example, Tomcat, Jetty, IBM WebSphere … ƒ Tailor server configuration to match application needs ƒ Dynamically ƒ Potential to combine all other approaches!

WAR Future? Servlet Servlet JSP JSP Servlet … App Server JSP Servlet Bundle Jetty Web Bundle Bundle Bundle HTTP … Web Equinox Equinox OS

26 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Advantages

ƒ Incremental update of server function ƒ Run multiple versions simultaneously ƒ Individual configuration and management ƒ Accommodate disparate application prerequisites ƒ Class loading performance ƒ Share components across client and server ƒ E.g., support disconnected mode

27 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Technical Challenges

ƒ Classloaders ƒ Classloader parenting ƒ Isolate nested entities from outside world ƒ Context Classloader use ƒ System property isolation ƒ Statics and factories in the JRE ƒ URLStreamHandlerFactory can only be set once

28 © 2007 by IBM Corp; made available under the Creative Commons Att. Nc Nd 2.5 license Cool stuff you can do

ƒ The Equinox runtime is extensible ƒ Hooks for enhancing the runtime behavior ƒ But be aware of the OSGi concepts ƒ it’s easy to break things

ƒ Modifying, for example ƒ Classloading ƒ Manifest contents ƒ Bundle contents ƒ Much more…

29 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Example: J9 Class Sharing

ƒ IBM J9 Virtual Machine offers class sharing across multiple running VMs ƒ Caches loaded classes for faster startup ƒ Shares loaded classes across VMs for smaller footprint

ƒ Equinox extension allows to make use of this ƒ A classloader hook that calls the J9 API in addition to the JDK classloading

30 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Example: Transformers

ƒ Transformers are additions to the runtime to modify the contents of bundles at load-time

ƒ For example removing extensions from the plugin.xml with regards to the active user ƒ Can be used to customize the app depending on the active user

31 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 AOP and OSGi

ƒ Equinox Aspect incubator project ƒ Adds AspectJ load-time weaving to the Equinox runtime ƒ Allows you to weave aspects into bundles at class-loading time

ƒ Modularity for aspects and bundles combined ƒ Case 1: ƒ Provide abstract aspects as bundles ƒ Case 2: ƒ Add aspects to the system and weave them into existing bundles

32 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Spring and OSGi

ƒ Spring is a de-facto standard for enterprise Java apps ƒ Dependency injection ƒ AOP ƒ Many technology abstractions and implementations

ƒ Spring-OSGi: ƒ New subproject ƒ Allows easy combination of Spring and OSGi ƒ Very promising for server-side and client-side apps

33 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Conclusions

ƒ OSGi is small, simple, easy and fast

ƒ It’s an ideal platform for general app development ƒ Even if you don’t use any of the other Eclipse technologies or platforms

ƒ Watch JSR 291: ƒ "Dynamic Component Support for Java SE"

34 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0 Thank you for your attention

ƒ Questions always welcome!!!

Martin Lippert [email protected] http://www.martinlippert.org/

Special thanks to Jeff McAffer for the material (see the Copyright statements on the slides)

35 OSGi and Eclipse Equinox Explained | © 2007 by Martin Lippert; made available under the EPL v1.0