Blewitt Small Print • These opinions are my own and not of anyone else • Various trademarks, service marks, birth marks, Groucho Marx and DeutschMarks are properties of their respective owners • The quality of this presentation may go down as well as up Wednesday, 21 September 11
Blewitt A Long, Long Time Ago • Back before OSGi was an acronym • ... when Java 1.2 had just been released • ... when people thought Swing was great • JSR 8 was proposed • Supported by IBM, Ericsson, Sybase • ... and Sun Microsystems This JSR is to develop the Open Services Gateway (OSG) Specification Wednesday, 21 September 11
Blewitt OSGi Releases • JSR8 was created in March 1999 • Withdrawn May 1999 • OSGi R1 – May 2000 • OSGi R2 – October 2001 • OSGi R3 – March 2003 > WAIT You wait – time passes. | | | | Wednesday, 21 September 11
Blewitt Eclipse 3.0 Switched to OSGi • Eclipse replaced custom plugin runtime with OSGi • June 2004 ➡Just when you thought you were beginning to understand how the Eclipse kernel worked, those pesky Eclipse developers replaced it all for Eclipse 3.0. The kernel is now built on another Java component framework, the Open Services Gateway initiative (OSGi) [FAQ] ➡Rather than creating a derivative OSGi++, the Eclipse community is contributing a number of important Eclipse features back into the OSGi specification • First time many had heard of OSGi ... • ... including me [FAQ] http://wiki.eclipse.org/FAQ_How_does_OSGi_and_the_new_runtime_affect_me%3F Require-Bundle! Wednesday, 21 September 11
Blewitt OSGi R4 releases • Since then, has been released every two years • 4.0 – October 2005 • Require-Bundle, Fragments, Singletons, Uses, Localisation • 4.0 Mobile – September 2006 (JSR 232) • 4.1 – May 2007 (JSR 291) • 4.2 – September 2009 • Framework Launching, Tracker • 4.2 Enterprise – March 2010, Blueprint, Remote Services • 4.3 – April 2011 • Generics, Weaving/Bundle/ServiceHooks, Capabilities • 4.3 Enterprise – first half of 2012, OBR Wednesday, 21 September 11
Blewitt ... and yet, OSGi isn’t everywhere • IntelliJ has a custom plugin system • Netbeans modules proprietary plugin • Java 8 will have its own way of doing things • Why is everyone avoiding proven technology? • Lack of knowledge? • Lack of marketing? • Lack of support? • Lack of tools? Wednesday, 21 September 11
Blewitt The Omega Problem • What is The Omega Problem? • OSGi projects are named in greek by geeks • Names usually meaningless on their own • Often part of a set-of-names (e.g. Zodiac signs) • Usually impossible to remember which is which • Unnecessarily increases learning curve for new learners Wednesday, 21 September 11
Blewitt Good Names • Spring • Spring Data • Spring Web Services • Spring LDAP • Spring Social • Spring Batch • Apache • Commons Lang • Commons IO • Commons Collections • Directory Server • Regexp Wednesday, 21 September 11
Blewitt Five Levels of OSGi – Denial • OSGi can’t possibly work! • OSGi – that’s written by IBM, right? • I use IntelliJ • IntelliJ isn’t Eclipse • Eclipse uses OSGi • Therefore I don’t use OSGi • OSGi is too complex for mortals to understand Wednesday, 21 September 11
Blewitt Five Levels of OSGi – Anger • Why can’t this bundle see this class? • Why am I getting ClassNotFoundException? I can see it! • These two classes have the same name, but aren’t the same. What gives? • Why can’t I see javax.swing? Or com.sun.misc...? • Why doesn’t hibernate work? Wednesday, 21 September 11
Blewitt Five Levels of OSGi – Bargaining • Please tell me why this uses constraint fails! • If you can start up the services in this order... • Why does this work in Equinox but not Felix? • Please let there be a Stack Overflow answer for NoClassDefFoundError ... • If I put ;resolution:=optional, please just start Wednesday, 21 September 11
Blewitt Five Levels of OSGi – Depression • How do I load a JDBC driver? • How can I map JNDI references to data sources? • Why doesn’t my custom Log4J logger work? • Why do I have to write a Manifest manually? • Why can’t I find a bundle for Apache Beanutils? Wednesday, 21 September 11
Blewitt Five Levels of OSGi – Acceptance • Sudden dawn of understanding of bundles • See how services can be connected with DS • Remote services to other systems • Dynamically upgrade code in running servers • Evangelise OSGi to others • Tweet about OSGi • Give keynote at OSGi community event Wednesday, 21 September 11
Blewitt µServices • Micro Services allow modular apps to be built • Essentially just OSGi services • Name used to distinguish from heavyweight SOA services • System as set of bundles → • System as set of interconnected services Wednesday, 21 September 11
Blewitt POJO Service Registry • Provides a µServices like view for non-OSGi Java • Allows you to use the same primitives for accessing services • All bundles use same classloader • So no issues with NoClassDefFoundError • Allows you to move to a µServices model incrementally • Doesn’t use the same namespace as OSGi • Trademark issues, not a standard OSGi spec • Can use Declarative Services for wiring up services • Goal would be to decompose app without code • Just use DS to build your system • http://code.google.com/p/pojosr/ Wednesday, 21 September 11
Blewitt Enterprise • Enterprise Specification come a long way • Database Drivers can be loaded in a modular fashion • Data Sources can be acquired from the factory • Objects can be mapped with Java Persistence API • Transactions can be managed with the Java Transaction API • Web applications can be hosted in an OSGi runtime • R4.2 Enterprise released March 2010 • R4.3 Enterprise scheduled for 2012 • Implementations progressing • Apache Aries • Eclipse Virgo/Gemini Wednesday, 21 September 11
Blewitt EJBs in OSGi • Tim Ward demo’d a runtime of EJBs in OSGi • Standard EJB metadata (annotation or xml descriptor) • Provides OSGi enabled annotation scanner • Bundle wires up dependency graph for application classloader • Can see the OpenEJB classes which are required • JPA entities are mapped to databases • Databases wired up with JNDI references • Transactions and contexts • Managed by container automatically • Session EJBs (views) registered as OSGi services • Can use EJBs and straight OSGi clients to access the data • Work in progress (e.g. no Security module yet) • Implementation to appear in Apache Aries Wednesday, 21 September 11
Blewitt Repositories • OSGi is in bad need of a standard repository • More than anything, a repository is what makes modular systems • Maven provided the go-to place for Java code • De-facto standard • Replaced trees like Giant Java Tree • Perl has CPAN • Python has easy_install • Ruby has gems • Linux distributions have packaging sites • RPM, APT, Yum etc. • OSGi has ... Wednesday, 21 September 11
Blewitt OSGi Repository Technologies • Eclipse P2 • Used to replace aging ‘site.xml’ update sites • Provides a metadata dump as well as contents of manifest • Very chatty network protocol • Files not optimised for network transmission • Non-trivial to mirror • OBR • Work in progress on Enterprise group • Not widely available • Single XML file • Uncompressed • Manual installation of bundles • install http://... p2 Wednesday, 21 September 11
Blewitt Ops4J PAX utilities • Pax utilities should be more widely used • wrap: protocol handler • Allows installation of JARs and auto-wraps bundle headers • mvn: protocol handler (pax-mvn replaced with pax-aether) • Allows installation of bundles via existing Maven repository • exam • Automated test client for OSGi utilities • logging • Mediator between OSGi logging and Log4J/SLF4J clients • runner • Automated launcher for OSGi applications • Could this be start for a universal launcher? Wednesday, 21 September 11
Blewitt Future OSGi Repositories • Need to provide modular repositories • All-in-one download of metadata not scalable • Minor updates cause entire re-download of file • Need to provide efficient repositories • Index file size problems • p2 index contain multiple redundant copies of EPL License • 1/3 of total index size is repeated EPL • No need for pretty-printed XML • No reason not to use compression (GZip, BZip) • OBR standard due next year • Hopefully will address some of these problems before release Wednesday, 21 September 11
Blewitt Example p2 content file ········<property name='df_LT.license' value='Eclipse Foundation Software User ... ········<property name='df_LT.license' value='Eclipse Foundation Software User ... ········<property name='df_LT.license' value='Eclipse Foundation Software User ... ········<property name='df_LT.license' value='Eclipse Foundation Software User ... ········<property name='df_LT.license' value='Eclipse Foundation Software User ... ········<property name='df_LT.license' value='Eclipse Foundation Software User ... <!-- EPL occurs 101 times in Eclipse 3.7 --> Wednesday, 21 September 11
Blewitt Cloud • Cloud systems are increasingly important • Management of OSGi process across machines • Virtual Machine technology will be prevalent • But management of processes not well defined • One machine per system is very wasteful • Deploying and configuring bundles will be key • OSGi + Remote Services solves scalability • OSGi + Repository solves install on demand • Base VM should provide OSGi runtime • Bootstrap all necessary data and code • Need a universal OSGi bootstrap process • Provision, deploy, configure Wednesday, 21 September 11
Blewitt Interoperability with legacy systems • OSGi Remote Services will be increasingly used • If you have OSGi on both sides, makes the most sense • What happens if you don’t have OSGi on both sides? • What happens if there are legacy APIs? • OSGi Remote Services needs interoperability • RMI for exposing OSGi service as RMI endpoint • RMI for consuming remote RMI as OSGi service • REST based API for non-Java clients (e.g. JavaScript) • JMS endpoint for message-based services • Often can’t upgrade both endpoints at once • Need to replace one at a time Wednesday, 21 September 11
Blewitt Enterprise improvements • Databases should be available under jdbc/DS • Most non-OSGi code will use jndi.lookup(“jdbc/DS”) • Not only osgi:service/javax.sql.DataSource • JPA should bind to DataSource services directly • Having Username and Password in JPA bundle is a layer violation • Prevents easy reusability if needing to use different accounts • Test/Production • Should not have any database-specific config in JPA bundles • Implementations should adapt dynamically • OpenEJB/Aries will make migration easier • Migrate existing code without changing • Map to existing databases and transaction structure Wednesday, 21 September 11
Blewitt Features, Apps, Bundles - oh my! • Better organisation of groups of bundles • Standardised means of representing • Subsystems • Features • Applications • Groups of bundles for single download • Will make management of large systems easier • May be integrated into OBR as capabilities • Part of Enterprise Expert Group work Wednesday, 21 September 11
Blewitt Tooling • Tooling still has room for growth • BndTools for creating OSGi-specific code • Maven Tycho replacing PDE/Ant builds for Eclipse • Manifest-first versus Manifest-last still being debated • Computer assisted development • Management of semantic versions automatically • Several proposals (including OSGi community event 2011) • PDE API baseline analysis • What if bundle hasn’t changed? Should it be rebuilt? • µService oriented design • Can we abstract bundles away and concentrate on services? • Scope for model driven design? Wednesday, 21 September 11
Blewitt Bridging the gap • Dependency Injection can wire up to services • Eclipse Sisu (based on Google Guice) provides JSR330 • Many developers familiar with JSR330 injection/annotations • Sisu used in Tycho, Maven and Hudson • Supports both OSGi and non-OSGi runtimes • Candidate for POJO SR hosting? • Migration recommendations • Hibernate -> JPA (EclipseLink, Aries) • JAXB -> Restlet • Spring -> Virgo -> Vanilla OSGi services Wednesday, 21 September 11
Blewitt OSGi Evolution • OSGi is still evolving • Core modularity is well understood • µServices becoming popular for system design • Enterprise Java support good starting point • Standard Repositories are a concern • Need to focus on higher level abstractions • Features, Subsystems, Applications • Need to focus on ease of use • OSGi mostly defines programmer APIs • Needs OSGi management applications Wednesday, 21 September 11
Blewitt OSGi Community • OSGi Alliance has work cut out • Defining specifications, moving forwards • Many jobs still need to be done • Education, Education, Education • Advocacy (Books, Blogs, Tweets) • OSGi in Practice/OSGi in Action/Patterns of Modular Architecture • Innovative solutions (PAX, PojoSR) • Population of OSGi wiki @ http://wiki.osgi.org/wiki/ • You can make this happen Wednesday, 21 September 11