This Blog is in continuation of my first blog on OSGi.
In the first part we saw what OSGi is and what benefits it offers. In this section I would like to share my experience in evaluating OSGi for developing a Web based application, the challenges I faced, Spring DM server and DM Server development tools for developing OSGi applications. Next I would also share some of my experience in using Spring DM Server for an actual development project
After doing my initial research of the OSGi framework I decided to start my journey on developing a sample Web based application on OSGi.
I soon realized my research is not complete and I still had to explore on how to integrate a Web based application within an OSGi container. I also had to explore on the development tools to be used.
Challenges in developing an OSGi based web application
I faced an interesting challenge here. OSGi applications need to work within an OSGi container whereas Web applications run within a Web Container.
To resolve this issue one can either embed the Web Container bundle (Tomcat bundle or Jetty bundle) within OSGi container or deploy the OSGi platform as a war within the Web Container. I particularly didn’t find these approaches amusing but with no other option left chose the first option.
Oops faced one more challenge here. Tomcat bundle was not readily available. I went through various forums and site where they explained how to build a tomcat bundle. Not to delay my progress I decided to use Jetty bundle which was readily available. It did take time for me to do the initial setup but finally I was set to start my development.
I was using PAX-Construct for handling the OSGi container and for deploying the various OSGi bundles. I went through the various steps that are required to develop a bundle and deploy it using PAX- Construct .I tried a few examples and found the steps to be too exhaustive and time consuming. Searching the open source library bundles manually, installing them and updating the Manifest file was becoming a nightmare. Instead of focusing on business logic my major time was getting spent in OSGi related activities.
My excitement about OSGi was coming down and I was thinking may be OSGi development tools are not matured enough and OSGi is best suited only for desktop based application. I wanted to have a simple deployment container for OSGi Web applications and easy to use development tools.
I wanted to do more research in this area before coming to a final conclusion and so I continued my research on OSGi in the web mode.
After going through several sites and forums I found the OSGi Enterprise Experts Group is working on the RFC66 standard for OSGi web container. I also came across several claims about Spring DM server being the best reference implementation of the standard. I didn’t come across any other implementation of the standard so couldn’t do much of the comparison here and finally decided to do more analysis of the DM Server.
Just after spending a couple of hours on the Spring DM server I found SpringSource has resolved both of my previous concerns. Spring DM Server served as a ready platform for deploying OSGi based web applications and Spring Source DM Server Tools provided very good Eclipse development environment for Spring DM server based applications.
Let’s have a look at what Spring DM Server and its development tools provides us
Spring DM Server
Key Capabilities Include:
Admin Console: deploy and manage artifacts, examine diagnostic dumps, and examine bundle wiring, either in the live system or from a resolution failure
Equinox console extension – manage DM Server and deployed artifacts
Plans - define the artifacts that comprise an application, optionally making the application atomic to tie the artifact lifecycles together, and scoped to isolate the application from other applications
Provisioning - automatically supply the dependencies of an application including bundles, plans, plan archives (PARs), and configurations, from both local and remote repositories
Web container - supports vanilla WAR files, with all their dependencies in WEB-INF/lib, and Web Application Bundles, that import their dependencies via OSGi manifest metadata, via the embedded Tomcat-based reference implementation of the OSGi Web Container specification, configured using the standard Tomcat server.xml
User Region - isolates the kernel from user-installed applications and enables admins to focus on application artifacts and their dependencies without seeing those of the kernel as well
Spring 3 –Spring DM Server packages Spring 3.0 final, but can easily be configured to use a different version of Spring.
Hot deployment - deploy artifacts to Virgo by copying them into the pickup directory, either in archive or exploded form, as an alternative to deploying via the admin console
Logging - via embedded LogBack, configured in config/serviceability.xml, with a rich set of appenders available out of the box
Spring Source Tool Suite
SpringSource provides a set of plug-ins for the Eclipse IDE that streamlines the development lifecycle of OSGi bundles and PAR applications. The SpringSource dm Server Tools build on top of the Eclipse Web Tools Project (WTP) and Spring IDE, the open-source Spring development tool set.
The SpringSource dm Server Tools support the creation of new OSGi bundle and PAR projects within Eclipse, and the conversion of existing projects into OSGi bundle projects. Projects can then be deployed and debugged on a running dm Server from within Eclipse.
Experience of using Spring DM Server in Live Project
I developed a sample Web application based on Spring DM server and its development tools. Once all stake holders were convinced we decided to use it for our next development project.
At the time of writing this blog its beings six months we have been using Spring DM server in actual development. Following are some of my experiences in this period:
To conclude OSGi provides a great platform for building modular Java applications in a true sense. OSGi is proven technology adapted by many open source and proprietary Java Enterprise servers and applications .Spring DM server looks promising as an OSGi web container and the DM server tools greatly simplify the OSGi development tasks. With the standardization of the OSGi web container specifications and Spring Source being actively involved in its implementation we would expect adaption of OSGi in many future Java Web application developments.
Finally I would support the quote posted on Spring Source site by Jan Hendrik Kuperus ‘ Spring DM Server is the future of Java EE’.
PS: At e-Zest, we work on emerging technologies & solutions based on OSGi component framework & Enterprise OSGi specification. Please feel free to email me your queries regarding OSGi on our corporate email id: info@e-zest.com.