OSGI in Java EE servers:Sneak peak

2,718 views

Published on

OSGi is steadily penetrating the Enterprise Java space, explaiting the complete lack of modularity in the Java EE specification. As this was introduced as a gap already at the time of Java EE 5 and still not addressed 6 years later - it's natural that alternative solutions will fill the gap.

At the same time - Java EE servers themselves decided to leverage OSGi to manage their own infrastructure. The session outlined the major Java EE Web Profile certified servers and validated the extent to which they expose OSGi to Java EE applications.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,718
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
24
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

OSGI in Java EE servers:Sneak peak

  1. 1. OSGi in Java EE servers: sneak peek insideKrasimir Semerdzhiev (SAP AG)EclipseCon Europe 2012 Pictures: Woodland Park Zoo
  2. 2. Why care at all?Most common application scenarios: Reuse open-source components: more than 80% percent of enterprises embed open source components in software /Source: SonaType/  Eclipse ones are (typically) OSGIfied  Apache/GitHub/GoogleCode/SourceForge/etc mostly have no OSGi packaging Modularize/”OSGIfy” Java EE applications Getting rid of proprietary module systems in favor of standard one(s). Anyone? Software refactoring and evolution© 2011 SAP AG. All rights reserved. 2
  3. 3. General approach – That’s our starting point!© 2011 SAP AG. All rights reserved. 3
  4. 4. General approach – How to eat an elephant? Java EE monolithic app Libraries in: lib META-INFlib WEB-INFlib Java EE container© 2011 SAP AG. All rights reserved. 4
  5. 5. General approach – Peter Kriens: One piece at a time! Java EE monolithic app Java Web Bundle Libraries in: lib Shared libraries WEB-INFlib Java EE container OSGi-enabled Java EE container© 2011 SAP AG. All rights reserved. 5
  6. 6. General approach – Peter Kriens: One piece at a time! Java EE monolithic app Java Web Bundle Libraries in: Shared libraries lib WEB-INFlib OSGi OSGi OSGi OSGi bundle bundle bundle bundle Java EE container OSGi-enabled Java EE container© 2011 SAP AG. All rights reserved. 6
  7. 7. General approach – Peter Kriens: One piece at a time! Java EE monolithic app Java Web Bundle OSGi bundle Libraries in: Shared Libraries lib WEB-INFlib OSGi bundle OSGi OSGi OSGi OSGi bundle bundle bundle bundle Java EE container OSGi-enabled Java EE container© 2011 SAP AG. All rights reserved. 7
  8. 8. General approach – Peter Kriens: One piece at a time! Projects typically stop at that state… Java EE monolithic app Web Bundle Shared Libraries OSGi bundle OSGi bundle Libraries in: lib WEB-INFlib OSGi bundle OSGi bundle OSGi OSGi OSGi OSGi bundle bundle bundle bundle Java EE container OSGi-enabled Java EE container© 2011 SAP AG. All rights reserved. 8
  9. 9. General approach – Peter Kriens: One piece at a time! Very unlikely to reach this state! Don’t worry! That’s OK! Java Web Bundle Java EE monolithic app OSGi OSGi OSGi bundle bundle bundle OSGi bundle Libraries in: lib WEB-INFlib OSGi bundle OSGi bundle OSGi OSGi OSGi OSGi bundle bundle bundle bundle Java EE container OSGi-enabled Java EE container© 2011 SAP AG. All rights reserved. 9
  10. 10. General approach – Keep the goal in sight!It’s not for those reasons: Single bundle can’t be reliably stopped! Java Web Bundle Single bundle can’t be reliably updated! OSGi OSGi OSGi bundle bundle bundle Reference caching further spoils the party! OSGi bundle Random startup order as a surprise for non- OSGi bundle OSGi bundle aware modules. OSGi OSGi OSGi OSGi Reference resolution for naïve package bundle bundle bundle bundle imports without a version might become tricky. OSGi-enabled Java EE container© 2011 SAP AG. All rights reserved. 10
  11. 11. We go for OSGi - which server to run on?Java EE 6 compatibility page (23.Oct.2012)Java EE 6 Web Java EE 6 Full profileprofile © 2011 SAP AG. All rights reserved. 11
  12. 12. Tested scenario: Granny’s address book Spring Spring Granny’s Spring (14) address book slf4j dom4j log4j Guava javassist Tomcat jdbc hibernate Apache juli cglib asm aopalliance antlr Source: Original sources + packaging on GitHub© 2011 SAP AG. All rights reserved. 12
  13. 13. Apache TomEE 1.0OSGi support None whatsoever  Neither uses, nor provides any Modularity: none – stick to Tomcat webapps  Libs can be put in [tomeelib] folder  No activators/resolution. Works like classpath.Overall experience Feels very lightweight even with a bigger WAR file. TomEE doesn’t currently support web.xml <resource-ref> definitions in web.xml. To be fixed soon. Doing partial application update is not supported by the server. Requires 3-rd party tools like LiveRebel for example.© 2011 SAP AG. All rights reserved. 13
  14. 14. Caucho Resin 4.0.32 freeOSGi support None whatsoever (but Why OSGi is cool, but not for enterprise apps blog) Modularity: Own “pomegranate” module system, dependencies in pom.xml  Additional JARs can be put in [resinext-lib] folder  No activators/resolution. Works like classpath.Overall experience Easy to handle No default datasource is bound in JNDI. Therefore app startup fails if not created manually.© 2011 SAP AG. All rights reserved. 14
  15. 15. JBoss Application Server 7(web)OSGi support JBoss own OSGI impl.  Tutorial available over here Additional bundles handling  Transform the WAR as a Web Bundle Archive (WAB) JAR.  Add the WAB + all related bundles in standalonedeployment “auto-deploy” folderOverall experience Easy to use! A bit hard to find the application web alias… Both web console + CLI admin deploy only single archives. No batching. Deployment passes successfully although bundles can’t be resolved at that time. Startup fails silently afterwards.© 2011 SAP AG. All rights reserved. 15
  16. 16. Glassfish 3.1.2.2 (web + full)OSGi support HK2 is based on Apache Felix Additional bundles handling  Deploy bundles one by one via asadmin CLI tool.Overall experience Deploy fails correctly on failed resolution. Have to handy-pick all dependencies one by one. Web console seems to cautiously ignore OSGi :-)© 2011 SAP AG. All rights reserved. 16
  17. 17. Apache Geronimo 3.0OSGi support Based on Apache Felix Additional bundles handling  Deployment via the Eclipse development toolsOverall experience Build as both Web Profile and Full Profile, but never cared to certify against the Web Profile© 2011 SAP AG. All rights reserved. 17
  18. 18. Other projects to watch out forWebSphere Application Server V8.5 Liberty ProfileEclipse Virgo© 2011 SAP AG. All rights reserved. 18
  19. 19. You still want to take the journey?Take a look at @glynnormington “Is OSGi modularity always worth it?”session.Management is very susceptive to “costs” and “ROI” arguments.Make the cost calculations carefully and use the numbers wisely!© 2011 SAP AG. All rights reserved. 19
  20. 20. Thank You!krasimir.semerdzhiev@sap.com Pictures: Woo

×