Showing posts with label Axis2. Show all posts
Showing posts with label Axis2. Show all posts

Monday, August 18, 2008

Exposing OSGi service as a Web service using Apache Axis2

As part of Axis2/OSGi integration process, we have implemented the basic facility to expose an OSGi service as a Web service. Still some of the advanced functionalities related to this function is in development stage and we will update the progress as we go alone.

In order to facilitate this, register OSGi service with Directory object with name/value pair "org.apache.axis2.osgi.ws/name of WS". This will create an AxisService with default Axis2 properties. This includes message receivers to be RPC*, default schema/targetNamespace generation etc.

You can test this out from here. Follow "axis2_osgi_integration.pdf" to set up the environment.

The example has registered a simple Calculator POJO as an OSGi service and exposed it as a WS. The name/value pair for this instance is "org.apache.axis2.osgi.ws/myCal". Then one will be able to observe

wsdl -> http://localhost:8080/services/myCal?wsdl
wsdl2 -> http://localhost:8080/services/myCal?wsdl2
A request -> http://localhost:8080/services/myCal/add?x=10&y=10

Wednesday, July 9, 2008

Partial solution to TCCL problem in OSGi

One of perennial problem that OSGi uses asked from mailing lists is to resolved the problem of TCCL. As I have mentioned in the blog post "OSGi and TCCL dilemma", there is no proper definition is available in OSGi R4.1 specification for TCCL.

On the other hand Eclipse Equinox OSGi implementation has taken steps to prevent this problem with the invent of ContextFinder (CF). When the framework starts, Equinox sets the framework TCCL to CF. Hence, all the bundles spawn from this framework will set its TCCL to CF. CF finds classes and resources from the classloader associate with the current method of the execution stack. (java.lang.SecurityManager#getClassContext). This is not the complete answer to the problem, but it will solve most of the common scenarios. Thus, it's very easy to use this concept and apply to other OSGi implementations as well, such as Apache Felix.

WSO2 is align with producing products that are OSGi enabled. The underline infrastructure of these products uses a product called "Carbon", which is an OSGi wrapper powered with either Eclipse Equinox or Apache Felix and provide a
Web Services infrastructure powered by Apache Axis2. Carbon uses the "servletbridge" design principle to bridge OSGi and Servlet container. Hence, Carbon is one such infrastructure that harness the benefits of server-side OSGi. Though Carbon defaults to Equinox and Felix OSGi implementations, it has give a very powerful API to integrate other OSGi implementations as well.

You will be able to find the source code from "svn co https://svn.wso2.org/repos/wso2/trunk/carbon".

Nice thing about Carbon is that it can switch between Equinox or Felix based on users preference. It can switched to any other OSGi implementations that is registered with too. Carbon uses the prior mentioned ContextFinder principle to solve the TCCL problem and I think it's a very fair assumption until OSGi specification mandate on the TCCL.

One of the very first product that is scheduled to be released on this month on top of the prior mentioned infrastructure is "Data Services Solution", which is a complete solution for data services via web services.

Saturday, July 5, 2008

Light weight, OSGi based, Axis2 powered, web services application server in 5 minuets

Few days back I blogged about "Embed Eclipse Equinox in a Servlet Container". Let's extend this idea a little bit more to write your own light weight, OSGi based, Axis2 powered, web services application server.

There is an ongoing effort to extend Axis2 Web Services engine to deploy as a bundle in an OSGi environment. The purpose of this extension is to allow deployed bundles to provide services and modules which will be recognized by OSGi based Axis2 engine and deploy them.

Let's create the light weight, OSGi based, Axis2 powered, web services application server using Eclipse Equinox OSGi implementation and Apache Tomcat.

1. Download Apache Tomcat
2. Download bridge.war from Eclipse Equinox.
3. Download commons logging (org.eclipse.equinox.common_3.3.0.v20070426.jar) bundle from Eclipse Equinox.
4. Copy the downloaded bridge.war to Apache Tomcat webapps directory
5. svn co https://svn.apache.org/repos/asf/webservices/axis2/scratch/java/saminda/osgi_test osgi_test
6. Go to osgi_test directory and type "mvn clean install -U". You need Maven2 build system.
7. Go to osgi_test/distribution/target directory and unzipped distribution-1.0.0.zip.
8. Copy all the bundles from distribution-1.0.0/plugin folder to /webapps/bridge/WEB-INF/eclipse/plugins and copy commons logging bundle too.
9. Restart Tomcat
10. On the osgi> command prompt start all bundles except fragment host bundles.

11. http://localhost:8080/bridge/services/Version?wsdl
http://localhost:8080/bridge/services/Version?wsdl2
http://localhost:8080/bridge/services/Version/getVersion

You have your personal light weight, OSGi based, Axis2 powered web services application server.