Monthly Archives: March 2011

exploring osgi, maven

I’ve started writing, hopefully a series of blogs about actually building a virgo app. Problem with greenpages is that nowhere are you shown how to roll your own.

So what I aim to do accomplish here is

  • a simple hello world app
  • built in eclipse w/ m2eclipse, sts
  • deployed from eclipse to virgo

Later on what I am most curious about is

  • managing online upgrades to existing deployment (as in, have a single deployment running at all times, do incremental upgrades on it)
  • eventually managing the deployment time user friendly
    • building safeguards against simulated application states (views) where data loss would happen, if we’d happen to upgrade for example before user submits a form
    • arranging so that safeguarded states cannot be entered after a upgrade preration has been initiated
    • could it be possible to give users a read-only access to the application while the new instance is starting up? (google code style)

Hello world tutorial

Starting out, for simplest hello world I found this, rather old tutorial which presents how to build the simplest bundle, and deploy it in an equinox instance. To update the original tutorial by Aneesh Kumar KB:

I will not referate that (good) tutorial here; go read it and try it. For me, the activator class was quickly compiled and bundled in, my first ever OSGi bundle is ready, easily started and stopped. That was not so hard.

You should note that if you kill the java process (CTRL-C) and restart it (after having the bundle installed and started) it will now start at launch. See the directory configuration under the directory you placed osgi runtime in. More about that in runtime options manual.

Hello world, maven style

Oki, so now lets do that with maven. As far as I know there are two ways of doing OSGi with maven:

  • Tycho — for what would seem like MANIFEST.MF first, pom.xml second development
  • maven-bundle-plugin — which does MANIFEST.MF generation from pom.xml

For me the obvious choice is to use later, the maven-bundle-plugin. Obvious because so far I’ve used maven to build many released and unreleased software products, both standalone and webapp and most importantly, I’ve finally realized how to use it effectively.

Creating maven project, no eclipse yet! Project structure:

  • test-parent (groupId=osgi.test, artifactId=test-parent, packaging=pom)
    • hello-bundle (artifactId=hello-bundle, packaging=jar)

Set up the directory structure, throw the previous Activator.java in test-parent/hello-bundle/src/main/java/osgi/test and add the following plugin:


<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <!--<Export-Package>we do not export</Export-Package>-->
      <!--<Private-Package>no privates either</Private-Package>-->
      <Bundle-Activator>osgi.test.Activator</Bundle-Activator>
    </instructions>
  </configuration>
</plugin>

When you launch maven to compile it, from the parent project, you’ll find that of course we need to add osgi framework dependency. Now… How does one find a prepackaged publicly downloadable equinox for maven2 dependency.

It took a while, but of course SpringSource has the bundle! As it’s so not nice to include code in wordpress blog, copy-paste the repository from faq question 8. The closest depedency to current 3.6 was 3.6.1* (more copypasting).

For what scope to use on the dependency, I’d guess “provided”, as it does not need to be included in any wars we might decide to build. (Looking how fast the bundle downloads, now might be good time to invest some energy on local artifactory or nexus instance.) Next up, compile again and it works now!

Even package works! A quick look at the generated archive reveals that maven-bundle-plugin was not bothered by our configuration; there are no OSGi specific MANIFEST.MF entries. This is because we specified packaging=jar, whereas it should be packaging=bundle.

Now lets see what happens.. At first it’d seem like maven downloads all the plugins in the world, but it’s finally ready. Again we have our jar in target/ and now it even has proper (I think) MANIFEST.MF entries. Now might be good time to read up how Bundle-SymbolicName is generated by the plugin (unless specified).

If you now attempt to launch the bundle and you notice that there’s a missing dependency: Import-Package: osgi.test; version=”0.0.0″, it’s because you mistyped the activator package name. maven-bundle-plugin will think you need to import that package, so that the activator can be run from there.

So, there you have it. Too bad wordpress does not allow me to link upload jars or tar.gz. Please comment if you’d like download final files. Original copyright of the amazing Activator.java belongs to http://aneeshkumarkb.blogspot.com/.

Next time I’ll try to modify this into HelloWorld servlet and try to get it up on virgo.

nouveau ftw

Recently I got tired of gradually slowing down performance of my entire desktop at work. It’d seem that the culprit was *drumroll* closed source nvidia driver.

After changing to nouveau everything is even better. In case I forget, the device is 8500GT. Though no DRI or AIGLX and wrong DPI. I tried to fix the DPI, nouveau says it configures it per EDID data but xpdyinfo tells otherwise) but didn’t get around it.

I also noticed that the only way to get “persisted” multihead configuration in Kubuntu 10.10 is to write xorg.conf manually.

eclipse helios w/ updates working

Today I decided to finally get Eclipse Helios finally working. After untarring I wanted to make sure that it’d finally have some sensible mirroring support — that it’d automatically select the nearest mirror and use it, instead of eclipse.org servers.

Help > Check for updates… hangs at 12% for more than 30 minutes. Quick dstat reveals that surprise surprise, no data is being downloaded from anywhere. Geez, I wonder what could it be?

It’d seem that p2 is still broken when it comes to mirroring. You can try to go ahead and switch the update site url’s to point to your favourite mirror, but it just wont help. If you look at p2’s actions while checking for updates, it might seem that it checks files on your mirror, but most of the GET’s are issued to <drumroll /> downloads.eclipse.org. Which is totally overloaded, perhaps because eclipse does this, and because it serves as the root for all mirrors.

One might ask the question – who do the mirrors serve? It is rather unclear, but the good news is that that the mirrors are traffic free.

Fixing it with squid (again)

To run an application, you’d think that you do not need a proxy server… You’d think. At least this was rather painless in ubuntu 10.10:


$ sudo aptitude install squid3

The following diff shows the minimum changes to /etc/squid3/squid.conf you’ll need to do:


--- squid.conf 2011-02-15 20:39:48.000000000 +0200
+++ /etc/squid3/squid.conf 2011-03-22 00:08:11.532438001 +0200
@@ -2787,6 +2787,8 @@
#Default:
# none

+url_rewrite_program /opt/squirm/bin/squirm
+
# TAG: url_rewrite_children
# The number of redirector processes to spawn. If you start
# too few Squid will have to wait for them to process a backlog of

As you can see, I’ll be using squirm to do the url_rewriting (because I don’t quite speak perl, or remember how to write python.)

Installing squirm is a bit more complicated, as you’ll need to build it by yourself; no ubuntu/debian packages that I’d know of. Basically you’ll just follow the squirm instructions, but change installation prefix to /opt/squirm and leave out configuring the redirect_program.

Sample $SQUIRM_ROOT/etc/squirm.patterns:


regexi ^http://download.eclipse.org/(.*$) http://ftp.ing.umu.se/mirror/eclipse/\1 ^http://download.eclipse

Final item on the list is to restart squid3 and configure eclipse to use 127.0.0.1:3128 for http, ftp proxy and you’re done. See, eclipse updates work again! By the way, it was the manual proxy settings provider.

Flash fullscreen on rv730 with latest x-swat updates

Amazing performance upgrades as I finally switched to x-swat (stable) ppa for Kubuntu 10.10.

Composition works and is pretty fast, for example compared to another my workstation with 8500GT using closed source nvidia drivers.

It’d seem that even GTK performance upgraded a bit. I was already using qt raster engine which made qt apps seem snappier. Too bad I code in eclipse and surf with firefox. With the driver and Xorg updates even GTK apps seem faster.

Side note; at home using this rv730, using qt raster does not mean any graphics artifacts. With nvidia stock 10.10 drivers qt raster didn’t work so well.

Fit-pc2i experiences

Yesterday I got my bought a fit-pc2i rev 1.2. Short summary:

  • Do not buy fit-pc2’s to be your media pc — HDMI does not transport audio
  • If you are planning to install any Windows on it, buy it pre-installed from Compulabs, they have some OEM goodness like HW accelerated codecs (plus it’s always horrible to install Windows)
  • Choose either (a platter disk AND heatsink) OR (an SSD disk AND no heatsink), because at least the Western Digital 5400rpm disk I plugged in stays at 45C at most of the time
  • If you are looking for a headless mini-server, choose fit-pc2i

I am going to be using this fit-pc2i to implement “a camera security system” to a remote location with bad Internet connectivity. Hopefully I’ll have time to write about that project more later.