Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Modular Web Applications based on OSGi - Jochen Hiller

318 views

Published on

OSGi DevCon 2008

The OSGi HttpService is very lightweight and restricted to very early Servlet specifications (missing filters, listeners, etc.).

This short talk will give an overview about a lightweight web container implementation based on the OSGi HttpService. This container will parse web.xml and add missing functionality (welcome files, filters, listeners) to HttpServices using wrapper technologies. This container service will also be provided as an Eclipse extension point and as bundle observing all bundles within the platform for a /WEB-INF/web.xml file (extender pattern). The implementation is very similar to specification of OSGI RFC 66 – OSGi web container.

Based on this service, a new type of web application can be designed. It is based on multiple small web applications (like WAR files, here: OSGi bundles) which can be combined into one single URI space, whereas the URIs can be mixed together on a deep level.

The talk will give an overview about the implementation, usage scenarios and probably a simple online demo.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Modular Web Applications based on OSGi - Jochen Hiller

  1. 1. 1 Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license Modular web applications based on OSGi Jochen Hiller March,18th 2008
  2. 2. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license2 The OSGi HttpService … •  is lightweight •  is restricted to Servlet Spec 2.1   no filters, no listeners, no welcome-files   no JSP support •  requires registration at HttpService   servlets / resources   programmatically   via extension point if using Equinox •  Equinox provides techniques to add missing functionality   see org.eclipse.equinox.http.helper classes from Simon Kaegi   but: complex, additional effort required
  3. 3. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license3 A solution: “Web Application Service” • The web.xml provides all configuration information • Parse web.xml to …  register all servlets and filters from contributing bundle  support specified welcome-files  add JSP support by default  add all mime-types, support default mime-types • Map web application to a context (alias in HttpService terms) • Resource lookup from contributing bundle • Binds to all OSGi HttpServices • The technique: register wrapper servlets • See https://bugs.eclipse.org/bugs/show_bug.cgi?id=162132
  4. 4. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license4 Web Application Service: The Service API package org.eclipse.equinox.webapp.service; public interface WebAppService { public Object registerWebApp( String alias, Bundle bundle, String bundleResourcePath, String webXml, Dictionary options) throws WebContextException; public void unregisterWebApp(Object handle); }
  5. 5. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license5 Web Application Service: As Extension point <!– web application service as extension point --> <extension id="webapp" name="DemoWebApp“ point="org.eclipse.equinox.webapp.registry.webapp"> <webapp alias="/" path="/WebContent"> </webapp> </extension>
  6. 6. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license6 Web Application Service: As Extender pattern • Follows Extender Pattern as proposed by OSGi • Bundle Listener observes all bundles coming / leaving the platform • Trigger file is /WEB-INF/web.xml • Context to register is bundle symbolic name  May be configured through /WEB-INF/osgi-web.xml
  7. 7. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license7 What are the benefits? • Easy development of JavaEE based web applications based on OSGi • Simplified deployment of existing web applications (WAR) to OSGi • OSGi can act as a lightweight web container • Implementation is not dependent on OSGi runtime implementation
  8. 8. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license8 Demo: Deploy Tomcat examples • Tomcat 5.5.x example applications  servlet-examples  jsp-examples • Changes required:  Create /META-INF/MANIFEST.MF  Added /WEB-INF/classes and /WEB-INF/lib/*.jar to bundle classpath  May be automated using bnd tool from Peter Kriens
  9. 9. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license9 Limitations, Plans • And what is missing?  Taglib support is missing  Listeners not yet supported  Declarative security not supported  Implementation under development, API may change  Documentation, Tutorials  More testing (e.g. compatibility with servlet bridge, other OSGi implementations) • Further ideas:  Equinox specific framework extension to directly support loading WAR files  Align with Enterprise OSGi and RFC 66 activities
  10. 10. Modular web applications based on OSGi | March 18th 2008 | Short Talk #244 © Copyright 2008 Jochen Hiller; Source code in this presentation is made available under the EPL v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license10 Questions? • Contact me:  jo.hiller@googlemail.com • Incubator project at:  http://sourceforge.net/projects/sse-examples  CVS, webapp-incubator

×