Developers, Developers, Developers! Maksim Sorokin IT Blog

18Sep/11Off

Maven + Apache Felix + CXF + DOSGi: An Example of DOSGi Service

Link in series

Link to two Felix instances

Here is yet another post in Maven + Apache Felix + CXF + DOSGi series.

Here I will show how to use Apache CXF DOSGi for cosuming remote services. You may see the sources on my GitHub account.

We will have

11Aug/11Off

Apache Felix: Running Two Instances of Felix Launcher in The Eclipse

This is a next post in Maven + Apache Felix + CXF + DOSGi series.

As was shown in the first post, one my have a separate project for Apache Felix in conveniently launch it using Eclipse.

You need to have two instance of Apache Felix running in the same Eclipse, for example if you are testing DOSGi remote services between different OSGi instances.

First, you will need to have two Apache Felix configurations. The first one can be default: conf\config.properties:

felix.auto.deploy.action=install,start
felix.log.level=1

org.osgi.framework.storage.clean=onFirstInit

felix.auto.start.1 = ...

Then you need to have second one for the second instance. Let's create it here: conf\secondConfig.properties:

felix.auto.deploy.action=install,start
felix.log.level=1

org.osgi.framework.storage.clean=onFirstInit

org.osgi.service.http.port=8081
org.osgi.framework.storage=secondCache

felix.auto.start.1= ...

Note org.osgi.service.http.port and org.osgi.framework.storage. Former is needed to tell OSGi to use different http port. The latter one specifies different cache for OSGi bundle (by default it is felix-cache), which is used to contain all started bundles.

Then the start configuration is the same as was described in the first post. For the second configuration one has to provide a location of conf\secondConfig.properties. In "VM arguments" specify:

-Dfelix.config.properties=file:conf/secondConfig.properties
9Aug/11Off

Maven + Apache Felix: Strategy to Handle non-OSGi Dependencies

This is another post in Maven + Apache Felix + CXF + DOSGi series.

Sometimes in the project plain Maven dependencies has to be used. A simple strategy to use those in OSGi project handled by Maven is to have a separate module, containing all non-OSGi dependencies and converting those to OSGi bundles using Apache Felix Maven Bundle Plugin.
So one may have the following structure of the project:

project
    ...
    project.nonOsgiDependencies
        project.nonOsgiDependencies.base64
        project.nonOsgiDependencies.mysqlConnector
        project.nonOsgiDependencies.xercesImpl

This nonOsgiDependencies projects would contain

2Aug/11Off

Maven + Apache Felix + CXF: RESTful Webservice with CXF. Using POST.

It is another post in Maven + Apache Felix + CXF + DOSGi Series.

In this post I showed you how to create a RESTful webservice consuming and creating a String. However, the example was using @GET method. Here I will show, what changes need to be done in order to consume input from @POST. As usual, sources are available in the end of the post.

Simply change @GET to @POST and remove

26Jul/11Off

Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. Consuming an Object

This is the following post in Maven + Apache Felix + CXF + DOSGi series.

Here we continue working with RESTful webservices. In the last post I showed how to returne an Object in XML with JAXB, and this post will based on it. In this post I will show how to consume an object. The title is rather misleading, but what I meant is "consuming XML and converting it to an object". Again, it is assumed that you followed the setup from the first post in the series. You will find attached sources in the end of the post.

We will have the same Felix Launcher project as in the previous post. To remind you, we will use

24Jul/11Off

Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. Returning and Object.

It is another post in series Maven + Apache Felix + CXF + DOSGi.

This example is based on a post about simple JAX-RS webservice with CXF. But this post describes a way how to return a more complex object, instead of a String.

First, we create a class in our test.bundle bundle MyMessage in package test.bundle:

package test.bundle;

public class MyMessage {

  private String message;

  public MyMessage(String message) {
    this.message = message;
  }

  public String getMessage() {
    return message;
  }
}

We will return this object in XML format to REST webservice requester. We will use

21Jul/11Off

Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. A Simple String Example.

This is next post in Maven + Apache Felix + CXF + DOSGi series.

This is example is based on the sample application developed in previous post. Again, it is assumed here that you are using M2Eclipse plugin, if you want to run examples from Eclipse.

As usual, source is included in the end of the post.

First of, we need to

20Jul/11Off

Maven + Apache Felix: Best Practices

This is another post in Maven + Apache Felix + CXF + DOSGi series. As was shown in Maven + Apache Felix: Easy Development and Debugging With Eclipse post, it is easy to develop projects with Maven and Apache Felix. But how about really big projects. How to maintain configuration and easily manage the bundles?

The answer is simple -- use the

19Jul/11Off

Maven + Apache Felix: Easy Development and Debugging With Eclipse

This is a first post on in series about Maven + Apache Felix + CXF + DOSGi. Here we will combine Maven, Apache Felix and Eclipse. You have to use M2Eclipse plugin for this (or similar Maven-Eclipse integration plugin).

The problem:

  • Integrating Felix with Eclipse tutorial requires manual download and configuration of Felix distributable into workspace
  • Felix allows deploying only jar bundles, which is inappropriate for easy development and debugging

We can use the power of Maven and these two resources to solve both problems.

The idea about the first one is to

19Jul/11Off

Maven + Apache Felix + CXF + DOSGi Series

This is a blog series on how to combine Maven + Apache Felix + CXF + DOSGi. The information presented may not be correct and some parts can definitely be improved. Not all posts are published immediately, so stay tuned!

Part 1 Maven + Apache Felix: Easy Development and Debugging With Eclipse
Part 2 Maven + Apache Felix: Best Practices
Part 3 Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. A Simple String Example.
Part 4 Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. Returning and Object.
Part 5 Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. Consuming an Object
Part 6 CXF RESTful Webservices: Running on a Different Port
Part 7 Maven + Apache Felix + CXF: RESTful Webservice with CXF. Using POST.
Part 8 Maven + Apache Felix + CXF: Securing a Service with HTTP Basic Authentication
Part 9 Maven + Apache Felix: Strategy to Handle non-OSGi Dependencies
Part 10 Apache Felix: Running Two Instances of Felix Launcher in The Eclipse
Part 11 Maven + Apache Felix + CXF + DOSGi: An Example of DOSGi Service