Friday, November 28, 2008

GGBLOG – Light weight reporting server on Equinox OSGi

I’ve been building software for quite a few years now and as software programming techniques have advanced, so has the number of layers.

Every once in a while a technology comes along which changes the way we think. Of late I’ve been hearing a lot about how cloud computing will allow us to scale our applications out. I think OSGi can give us similar results at a micro level by removing the traditional boundaries and layers on which our java applications are currently built.

OSGi heavily encourages the breaking up of our applications into bundles or modular components which can be readily plugged into mobile, desktop and server architectures.

I’m forever trying to update my 90’s programming style, so in attempt to get up to speed with OSGi I’ve put together a light weight reporting server based on Equinox OSGi and Jasper Reports 3.1.2.

If you’d like to have a look at code and get the demo running feel free to follow the steps below.

Running the Demo

Download the the file from:

Once downloaded, unzip it onto your local pc and open Eclipse 3.4 and select the directory which you unzipped to.

Click the down arrow next to the run button and select Run Light Weight Jasper Server

If you see the following the server is now running.

Copy test.jasper, test.jrxml and test.xml from file to /temp/ (c:\temp on windows).

Open up a web browser and paste the following url.


You should get a prompt like the following.

Open with adobe reader and if you see the following pdf, you have the demo successfully running.

Optional Step: if you want to change the report download iReport 3.1.2 and open up /temp/test.jrxml and compile the report back to /temp/test.jasper, no need to restart the server after you recompile the jrxml.


I ran a quick burn test and right out of the box with no tweaking or tuning, the server managed to generate 56 pdfs/second or 3,358 pdfs/minute on a Core 2 Duo 2.4 ghz with 2 gig ram (Win XP).

If I ever need upgrade/dowgrade the jasper distribution I simply create a new jasper reports bundle and configure the runtime dependencies via Equinox. If this were a traditional webapp I’d have to worry about breaking other modules that live inside WEB-INF/lib or within the shared app server lib directory.

If you have any troubles/questions with the demo or want to know a bit more detail on any specific area feel free to drop me a line (

Sunday, November 23, 2008

GGBLOG – Chat on the RAP

I thought I’d check out the rich Ajax platform and see how well my RCP skills carry across. My first impressions are that I’m feeling pretty much at home on the RAP.

The vision of single sourcing is upon us and has huge potential to vastly reduce the amount of code we need to write where similar functionality is to be delivered on both a web browser and a rich desktop client.

I’ve put together a fairly primitive chat room that uses the rich ajax platform we’ve all been hearing a lot about. If you’d like to install it and have a look at the code you can follow the steps below.

Install the rich ajax platform, taken from

For Eclipse 3.4 or later...

  • With Eclipse up and running, select the Help > Software Updates... menu entry.
  • Select the Available Software tab and click the Add Site... button.
  • In the upcoming Add Site dialog, enter enter the RAP Update Site URL Click OK to create the new update site entry.
  • The entry you just created now appears in the update site list. Select its check box and click Install....
  • The Install wizard will let you review the selected items to install, confirm with Next to continue the installation.
  • Accept the terms in the license agreement and click the Finish button.
  • The feature and plug-ins will now be downloaded from the site and installed locally. Note that you may be prompted to confirm if it is ok to install unsigned jar files.
  • Confirm the following prompt to restart Eclipse.

After Eclipse restarts, a welcome page is displayed. Select the Rich Ajax Platform (RAP) section and choose Install Target Platform on the following page. In the upcoming dialog confirm the default values, which starts the target installation process.

Once RAP is installed into eclipse, download and import from

- Click file -> import -> Existing Projects into workspace

Select archive file, Click browse, lockate on your local pc, click finish:

Your eclipse should look something like this after the import has finished:

Right click the , click run as , click, click send message and you should get the following. Notice the validation messages working just like they do in RCP.

Start up Internet Explorer/Other, copy and paste the url and append &theme=org.eclipse.rap.dw.demotheme to see RAP themes in action and to simulate another chat client. Feel free to leave a comment if you have any trouble installing. Ill try to answer as soon as I can.

Thursday, November 20, 2008

GGBLOG - Format the Nebula

The nebula project has a cool set of widgets for SWT which can be readily used in a RCP application.

I was playing around with nebula CalendarCombo and wanted to give it my own date format. As usual I started to read the source code and found that all you need to do is to define your own settings class, override getDateFormat and give it to the CalendarCombo constructor


new CalendarCombo(parent, SWT.NONE, new Settings(), null).

Settings class example below.

public class Settings extends DefaultSettings {

public Locale getLocale() {

return Locale.ENGLISH;


public String getDateFormat() {

return "dd/MM/yyyy";



Friday, November 14, 2008

GGBLOG - Dynamic jface XML TableViewer Tutorial

The following tutorial will show you how to build a dynamic jface TableViewer driven from an xml file. The beauty of this solution is that your data model is decoupled from view logic so when the xml data changes you don’t need to change the concrete code.

It’s a pretty simple tutorial which should take around 5 – 10 minutes to complete.

Step 1. Create a new project in eclipse 3.4

Open Eclipse -> Click File -> new Plug-in project -> Next

To keep the examples simple type galang.research in the project name and click next. You can type any name you want though you’ll need to factor this into all the code samples I will provide.

Select Yes in the Rich Client Application section, click next.

Select RCP application with a view, click next.

Select Add Branding.

Click finish, then Yes.

Unzip the file located at the URL below and save the test.xml within the zip file as /temp/test.xml to your local pc.

Right click project and configure build path, link source, then click browse and select the src location to where you have unzipped the file above.

Enter srcExt fo folder name

Your package explorer should look like this.

Modfy in the galang.research package with the following code.


* This is a callback that will allow us to create the viewer and initialize

* it.


public void createPartControl(Composite parent) {

viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL


viewer.setContentProvider(new RowContentProvider());

RowLabelProvider labelProvider = new RowLabelProvider();





And add the following imports to

import galang.research.jface.RowContentProvider;

import galang.research.jface.RowLabelProvider;

Double click plugin-xml and click the Lanch eclipse application.

Congratulations, you’ve just completed this tutorial. Have a play around with the /test/temp.xml and see how it dynamically impacts the RCP application after restarting it.

Wednesday, November 12, 2008

GGBLOG - Stringy Combo

If you ever find yourself writing some RCP code and end up struggling with the standard ComboBoxCellEditor, I highly recomend you try out the the excellent editor published by John Mason, see below

It basically does away with the awful mapping to and from selection index and deals with plain old java strings (POJS) :).

Have fun!

Monday, November 3, 2008

GGBLOG - Border Dispute

I've been playing around with Eclipse RCP lately and have found the eclipse forms a great way to prevent your application looking like ye olde VB app.

If you ever start using eclipse forms and find your text boxes don't have borders see if you have this line of code at the bottom of your eclipse form code.


If you don't have this your text boxes will apear invisible against the default white background colour.