Monday, April 27, 2015

Maven Shade Plugin to bundle all the SCIs

We are having an Tomcat OSGi bundle which consist of following dependencies.
<artifactId>tomcat-dbcp</artifactId>
<artifactId>tomcat-embed-core</artifactId>
<artifactId>tomcat-embed-jasper</artifactId>
<artifactId>tomcat-embed-websocket</artifactId>
Both tomcat-embed-jasper and tomcat-embed-websocket contains SCIs. I wanted to bundle these dependencies to a single OSGi bundle with all their SCIs. If we use maven-bundle plugin as follows

Since all the SCIs use the same interface javax.servlet.ServletContainerInitializer, based on the order we specify the resource previous references get override and only the last resource SCI will get bundle.

We can use maven-shade-plugin to overcome the issue. It has lot of other features as well. You can refer to the official documentation page for more details about shade-plugin
Maven-shade-plugin

If you wanna combine all the META-INF/services (like what I wanted to do) you can use following configuration

Saturday, April 18, 2015

Image Filtering with OpenCV

Last year I wanted put my hands on JavaCV and play little bit with that. But with time I couldn't continue that. Few weeks back I again got that crazy feel "The Machine" :D So I wanna start it again. But this time with c++.

Install OpenCV
I found a nice post that describe step by step to install OpenCV on ubuntu. You can follow that tutorial and get OpenCV on your machine. (If you are on Windows then it is just installing the .exe)
Installing OpenCV 3.0.0 on Ubuntu 14.04
In the post he is using OpenCV 3.0 alpha version. But now beta version is also available. I'm using the Beta version here. Just download the beta release from the officail OpenCV website. http://opencv.org/downloads.html
Then you can follow the same steps as mentioned.

Image Filtering
I'm not going to describe about what is image filtering or why we need that. You can find plenty of information about these topics if you really keen on. I'm just gonna show up the code that can be use to do Mode filtering and Median filtering.

Median Filtering
In Mode filtering what we do is simply break image into 3x3 segments and assign the median of those pixel values of each segment to the center pixel of the each segment.

Mode Filtering
In Mode filtering what we do is simply break image into 3x3 segments and assign the mode value of each segment to the center pixel of the each segment.

Sunday, April 12, 2015

How to Change WSO2 Carbon Version

Few days ago I faced a problem where, when I trying to build the carbon-commons with Tomcat 8 supports though I changed the Tomcat version it is picking dependencies from previous Tomcat bundle. I tried clean repo, deleting local repo several times but couldn't get through this. When I changed the carbon kernel version and build the commons with that then problem get fixed.

In order to change the carbon version
  1. Change version in all the pom.xml files in the Carbon-kernel. At the moment it is 4.4.0-SNAPSHOT. You can easily do this by a Replace All command in your IDE or if you are a terminal guy, you can use grep/find commands
  2. Then you must change the version in distribution/kernel/carbon.product file. It has version in 2 places. Changed both occurrences to your new version.

Then can do the build without any issues.