There is ongoing work in the Axis2 project to make Axis2 engine not only compatible with OSGi but also take all the advantages that OSGi infrastructure provides, so developers could deploy Axis2 Web Services and Modules in bundles. This article aims to provide a template application which allows launching Axis2 in an OSGi Environment within seconds. The application is runnable with Felix and Equinox in Java Environments JDK and JRE versions 1.5 and 1.6.
Archive axis2-osgi-example.zip contains the Template Application with one Web Service "Version Web Service" whose WSDL is accessible from "http://localhost:8080/services/Version?wsdl" and an Axis2 Module with two handlers which are bound to the Web Service. The application also contains a Web Admin interface which is accessible from "http://localhost:8080/system/console/list". If you would like to change the port in use (8080) then make sure to check the readme.txt file.
You can run the application by executing either the batch/script file in the "/axis2-osgi/bin" directory or by executing the following command from the "/axis2-osgi" directory:
> java -jar ./lib/da-launcher-1.0.2.jar
Key Implementation Issues
- DA-Launcher is used to launch the application: DA-Launcher is used to launch the application as such the application can be configured easily to run with Equinox or Felix and Web Service bundles can be installed/uninstalled by simply copying/removing bundle archives in the Application Bundles directory.
- Bundles: Axis2 and Axiom bundles are placed in the System Bundles directory "/axis2-osgi/bundles/system-bundles" and user bundles (Web Service and Module bundles) in the Application Bundles directory "/axis2-osgi/bundles/application-bundles".
- Non-bundled libraries: I used about 12 non-bundled libraries (JAR files that has no OSGi headers) and left them for DA-Launcher to generate bundles from them. So when you run the application for the first time DA-Launcher will generate bundles from the non-bundled libraries then cache them, so next time you run the application, DA-Launcher will use the cached bundles instead of regenerating them. Non-bundled libraries are placed in "/axis2-osgi/bundles/non-bundled-libraries" directory.
- Pax Web Service: To remove the dependency on Equinox Framework, I used Pax Web Service bundle as the Http Service for the application. The Pax Web Service bundle provides the implementation of the HTTP Service defined by OSGi Service Compendium specification and contains Servlet API and Jetty Web Server Engine classes.
- Snapshot version of Axis2 and Axiom: Axis2 and Axiom snapshots were used since there were no releases for them.
- Modifications to Axiom sources: The only modification to the source code of Axiom was specifying the version "1.0.0" for the imported package "javax.xml.stream". No modifications were done for the source code of Axis2.
You can deploy your own Web Services and Modules by copying the bundles that contain them to the "/axis2-osgi/bundles/application-bundles" directory.
Unfortunately, this template currently can't be run with Knopflerfish.