Blogs

Develop with Eclipse - Deploy with Maven

In the previous Declarative Services in Apache Karaf entry the creation of a Karaf feature is demonstrated. One can create the feature by simply running `mvn clean install` at the root of the source code (available at GitHub). This will build and install all projects in the local Maven repository.

Logging in Apache Karaf

Apache Karaf provides a powerful logging system based in OPS4j Pax Logging. Besides implementing a standard OSGi Log Service, it also supports all major logging APIs (Apache Commons Logging, SLF4J, Apache Log4j, Java Util Logging). So no matter what API your libraries are using, Karaf can log messages from them.

For new bundles I suppose that a good choice is SLF4J. This is a modern API that offers parameterized log messages. In Java code one usually creates a static logger:
 

Karaf and CXF DOSGi updated

The Aniketos Runtime platform is based on Apache Karaf OSGi container. Another key technology for the platform is Apache CXF DOSGi. This is an implementation of OSGi Remote Services that allows services in different containers to be discovered and exchange information. In a simple scenario, CXF DOSGi can also be used to provide a SOAP WSDL service from inside an OSGi bundle. This service can be consumed from either an OSGi client in another container or a common WSDL client.

Declarative Services in Apache Karaf

In this post I would like to demonstrate how easy it is to use Declarative Services in Karaf. The source code will be based on the Converter service and client that were used in a previous example about remote services. This time however both the service and the client will reside in the same OSGi container and instead of Activators Declarative Services will be used.

OSGi Remote Services

Remote Services is a feature introduced in the 4.2 version of the OSGi specification. It provides a way for accessing OSGi services from remote OSGi containers. CXF DOSGi is an open source implementation of Remote Services.

Using WRAP protocol to install bundles in Apache Karaf

The WRAP protocol provides a convenient way to install bundles in Apache Karaf in many situations. I will try to describe it here with some real examples.

First let us try to install ecj-3.5.1.jar. This is the Eclipse Compiler for Java bundle and can be downloaded from a Maven repository.

Start Karaf and type:

Easy installation of bundles in Apache Karaf

Easy installation of bundles in Apache Karaf


Apache Karaf provides many convenient ways for bundles installation:

Spring JDBC in OSGi

Spring JDBC provides an excellent alternative to the dreadful Java JDBC API for accessing a database. However, using it in an OSGi container isn't so easy, as there are some pitfalls to avoid. I will try to describe here a solution to this problem.

Test Database

First let's create a test database. We are going to use MySQL. Open a MySQL command prompt and type the following:

Syndicate content

ANIKETOS newsletter

Stay informed on our latest news!

Login

Only for users who has an user and a password sent by the administrator.