OSGI implementation with Apache Karaf

Karaf is lightweight container for OSGI. In karaf, beside OSGI Core, we have other additional feature for support our application, in other words. Karaf is osgi container that ready to used. Not like Felix or Equinox, they are just OSGI core runtime, if you want to used it with integration for example with apache camel or apache cxf, you have to add those feature manually. Here is picture that i take from karaf website

Continue reading OSGI implementation with Apache Karaf

Subversion : How to adding file/folder to ignore list with command line

Maybe we had known how to add file or folder (from this time and so on I will just said “file”) on IDE. On this case, I often using Eclipse, and adding file as ignore list in eclipse is like shooting fish in a barrel. But occasionally we have to using command line to complete it. and do not worry, this is not too difficult. I will show you how 🙂

There are 2 condition of file that we want to ignore. First, the file is already in svn repo and the others not in svn yet. How we tackle these? Remember to always remove file from svn repo first for this case. because we can not add file to ignore list while the file is on the repo. What we have to do just go to directory of our repo in local, and just do command below :

Continue reading Subversion : How to adding file/folder to ignore list with command line

JAXB Tutorial

JAXB stands for Java Architecture for XML Bindings. In a nutshell, JAXB used for convert Java Object to XML and vice versa. We called it marshalling to convert Java object to XML and unmarshalling to convert XML to Java object. JAXB bundled in Java 1.6++, so we do not need another external libraries (but sometimes I loved to adding testing and logging framework). First, you have to know the technology that I used in this tutorial are :

  1. Maven 3
  2. TestNG (for unit test)
  3. commons-io

Some of you would frown and said “hmm, why you put commons-io on this tutorial?”. Simple, I used it in unit-test to get xml file from resource folder and convert to String, I know it can be done with the classic inputstream ways. but remember to not reinventing the wheel 🙂

Continue reading JAXB Tutorial

Change CXF based address in OSGI Service

By default, CXF will mapping CXFServlet to /cxf context path. I used Servicemix 4.5 which using CXF 2.7.3 inside. its define static in osgiservlet.xml in cxf-rt-transport-http (FYI, for CXF 2.7.3, they are using transport-http ver. 2.6.3). So, based on default configuration, all our CXF service will result like http://localhost:8181/cxf/myservice, this is not good. because sometimes you want define service itself.

Continue reading Change CXF based address in OSGI Service

Problem using JaxB marshalling/unmarshalling within OSGI container

I ever had a problem when want to using Jaxb in Servicemix 4.x which used OSGI. Like documentation describe on this page, we will know how to use Jaxb with apache camel. What we have to do is adding line below :

DataFormat jaxb = new JaxbDataFormat("com.foo.bar");

from("activemq:My.Queue").
  unmarshal(jaxb).
  to("mqseries:Another.Queue");

Above endpoint will route the jaxb unmarshal result to another queue. JaxbDataFormat will automatically search entity with JaxB @XMLRootElement inside package. But you will get a problem when implemented those code in OSGI. here is the error message :

Continue reading Problem using JaxB marshalling/unmarshalling within OSGI container