Configuring RCP applications with Pax ConfMan

July 10, 2009

Most applications require configuration settings. Applications are often deployed in multiple environments (dev, test, prod, etc) and these environments often require different runtime configurations. Also, it’s useful to be able to update an application configuration without a restart. If you find yourself with requirements like these for your Eclipse RCP application, you should really check out the OSGi Configuration Admin service.

Specifically, the Configuration Admin service allows you to:

  • Configure the OSGi services that you provide as part of your application.
  • Configure OSGi services that others provide. An example of this is the ability to configure the Pax Logging service, which I’ll explore in a second post.
  • Configure Spring beans when using Spring DM. Here is a good reference for using Config Admin with Spring DM.

If you’d like to learn more about the Configuration Admin service, check out this post or the OSGi Compendium specification. In this post I’m going to describe how to set up the Configuration Admin service in an RCP application using Pax ConfMan.

What is Pax ConfMan?

The Configuration Admin service doesn’t specify any particular way of storing and accessing properties. Each implementation can do what it likes, and Pax ConfMan has opted for the simplest approach – properties files.

Setting up the target platform

The first step in getting Pax ConfMan working in your RCP application is to add the required bundles to your target platform. Here is the complete list of bundles which need to be added:

  • org.eclipse.equinox.cm (download)
  • org.eclipse.osgi.services (download)
  • org.ops4j.pax.confman.pax-confman-propsloader (download)
  • org.ops4j.pax.logging.pax-logging-api (download)
  • org.ops4j.pax.logging.pax-logging-service (download)

Also make sure to add these bundles to your product configuration and run configuration so they will be included in builds and at runtime.

Forcing Pax ConfMan to start

If you run your RCP application at this point and examine the running bundles in an OSGi console, you’ll notice that the bundles added above are not started. To make the service available at runtime, we need to force them to start using the Configuration page (new in Galileo) of the Product Configuration Editor.

This page allows us to specify that specific bundles should be automatically started when the application is launched. Note that adding bundles to this page currently wipes out necessary RCP bundle settings. After adding these back in, your config page should look like this:

confman-1

Now if you run your RCP application, you should see Pax ConfMan logging output to your console. These logs will tell you that the configuration folder cannot be found. So on to the next step!

confman-2

Adding a configuration folder

Pax ConfMan allows you to configure your OSGi application using standard Java properties files, so we need to create a directory to hold these files. To get started, create a folder called confadmin in one of plug-ins that is part of your RCP application. You can call this folder anything you like, and the ConfMan default is configurations. I think confadmin is a better name in that it distinguishes it from the configuration folder used by the OSGi framework.

Inside the confadmin folder, create two sub-folders called services and factories. These folder names are required.

confman-3

Finally, you need to tell Pax ConfMan where your folder is located, and this is done using a Java system property called bundles.configuration.location.

When running inside the Eclipse IDE, the simplest way to do this is to add an argument to your run configuration. Mine looks like this:

confman-4

Now when you run the application you should see ConfMan messages indicating that your configuration folder has been located. Of course we haven’t added any properties files yet, but the wiring is all in place.

How to handle deployment

There are a variety of ways to handle configuration files in a deployed RCP application:

  • Place your configuration files in a separate bundle and deploy that bundle as a folder instead of a jar file.
  • Add your configuration folder to the install directory by utilizing the root property in the build.properties file for a feature.
  • Use an installer script to copy the configuration files into another directory on a users machine.

No matter which option you choose, you’ll need to provide a bundles.configuration.location VM argument that points to the configuration directory.

What’s next?

Well you can now start to configure your own OSGi services using Pax ConfMan. In my next post I’ll show how to use ConfMan to configure Pax Logging in an RCP application.

Advertisements

RCP-based Marketcetera featured in the NY Times

January 15, 2009

It’s not every day that an Eclipse Rich Client Platform application is covered in the NY Times. In fact, I can’t remember it ever occurring before.

But yesterday Marketcetera, a developer of RCP-based open-source trading software, was featured in the Bits Blog of the NY Times. Of course there’s no mention of RCP itself, but it’s nice to know that those building tools with this framework are having some success.

Yesterday also marked the 1.0 release of this product, so congratulations to everyone at Marketcetera! I’m sure I speak for everyone in the RCP community when I say we wish you all the best.


What I’ll be attending at Eclipse World

October 27, 2008

Tomorrow I head to Eclipse World and after doing so much training I’m really looking forward to sitting and listening to others for a change! I am going to be doing a few presentations at the conference, but in this post I wanted to focus on what I’ll be attending next week.

Converting Your Applications From Swing to SWT and the RCP

This topic is becoming increasingly important to my clients. I’ve seen more than a few projects that are trying to leverage existing AWT/Swing resources as they migrate to RCP and are struggling with how to do this properly.

Creating Graphical Editors and Views Using Eclipse GEF

I’ve used GEF occasionally over the past few years, but I’ve never had the opportunity to hear it described in a systematic way. I’m also excited to hear some more about Zest, which I’d love to start using in upcoming projects.

RAP or GWT: Which Java-Based AJAX Technology Is for You?

RIA technologies look to become central to future Eclipse architectures (see the e4 project for the details). I have to admit I’m still somewhat ambivalent about thin-clients and would rather see rich clients with awesome provisioning support instead.

Java UI Testing Patterns and Best Practices

UI testing is always problematic and I think approaching this topic from a patterns and best-practices angle makes a lot of sense. I’m particularly interested in ways to create UIs that are designed to be testable.

So that’s what I’ll be attending this year, and if you see me at the conference be sure to stop me and say hi. And if anyone is interested in having a beer or something, just let me know!


Public RCP Quickstart course in Washington DC area

October 14, 2008

I try to keep marketing posts to a minimum on this blog (I think this is my first one…), but I’m excited to say I’m going to be offering my first public RCP Quickstart course in early November. I often get requests for RCP training from smaller groups of developers and up to this point I haven’t been able to meet this need. Finally, I’ve managed to find the time to schedule a public course that may work for these developers.

So if you’re interested in RCP training and the Washington DC area is convenient for you, I hope you’ll consider attending in November. To get started, you can check out the course syllabus and registration information.

On a slightly different note, I’ve just finished offering my first remote training course to a group of developers in Australia (hello to the gang in Melbourne!). The course went extremely well and it’s got me very interested in offering further remote courses. I’d be willing to offer public or private remote training classes for fairly small groups, so this may also be an option for smaller development teams, or for those in Australia 🙂


Creating a good presentation

September 15, 2008

We all like to attend conferences and most people like the idea of presenting at one. But when the excitement of your submission acceptance fades, many of us sit down to face an empty PowerPoint deck and wonder where to start. Creating an effective presentation is a difficult task and it’s made even more difficult by the fact that most of us have never been taught how to do it. 

I’ve spent some time this summer thinking about presentations and reading what I can on the subject. I’m hoping this makes me a better communicator, and in any case I now know what I’m doing wrong! For those of you currently working on presentations or thinking about submitting for next year’s EclipseCon, here are two books I highly recommend.

Presentation Zen

This book by Garr Reynolds is fundamentally about getting your head in the right place. Stylistically, the emphasis is on graphical simplicity and storytelling, but to me the best parts were those that got me focused on why I want to present in the first place. Read this book first to get inspired by what great presentations can accomplish. And also check out Garr’s blog which is full of good information.

One of the best suggestions Garr has is to watch great presenters at work. Spend a few hours watching TED presentations, and you’ll have a new appreciation for how good a presentation can be.

slide:ology

Nancy Duarte’s claim to fame is that she developed the slides used by Al Gore in his talks about global warming. In this book she goes into great detail about how to create an effective presentation. The emphasis here is on the nuts and bolts of creating (but not giving) a presentation, and believe me if you’re not a graphic designer this information will help a lot. By the way, this book is also available on O’Reilly’s Safari Books Online.

 

If you act on the information in these two books, you’ll be well on your way to becoming a great presenter and your audiences will thank you for it.

I’m in the early stages of incorporating this material into my work, but I can already see some benefits. And if anyone in the Chicagoland area would like to see where I’m at right now, I’ll be speaking tomorrow (September 16th) at CJUG on the topic of “OSGi: Why Java Modularity Matters”.


Using Clover with PDE Build

September 11, 2008

In a previous post I mentioned that I had not yet found a way to use Clover to perform coverage analysis when running PDE Build and the Eclipse Testing Framework. A very kind reader (thanks Nihal!) has posted a comment outlining how to get this combo running. I have to tell you, the solution is not for the feint of heart. But if you really need to use Clover, give it a try. As for me, I think I’ll stick with EMMA.

On a different note, I’m currently in the Houston airport catching a flight out before Hurricane Ike hits. To any Eclipse developers living in the Houston area (especially the students at this weeks RCP Quickstart class), stay safe and I wish you all the best.


How to brand Eclipse RCP?

August 7, 2008

In response to my last post on Eclipse RCP Trends, Chris Aniszczyk commented:

Deep down inside… I think it’s a marketing issue… we have done a poor job marketing RCP in my opinion. We have brand confusion that when people hear Eclipse still they think IDE, not a rich client platform. It’s my hope that with the new Runtime project, we have a chance to rebrand Eclipse into more of a platform under the Equinox umbrella.

I couldn’t agree more, and I’ve spent some time this summer trying to wrap my head around this issue. I should say up front that I have zero marketing experience. But on the other hand, I have spent a lot of time with RCP newcomers and have some experience viewing this technology through their eyes.

So what did I come up with? Well this might sound pretty obvious to some, but my conclusion is that RCP = modularity. Period. If you want to assemble (dynamically or otherwise) an application from a set of components/plug-ins/bundles/whatever, then RCP is the tool for you. Sure it’s a UI toolkit, sure it offers a workbench, preference pages, etc. But the core idea that animates RCP is modularity.

The good news is that Java modularity in general and OSGi/Equinox in particular are playing an increasingly important role in software development. We need to ride this trend and make clear that RCP is the visual expression of Java modularity. When you want to apply the principles of Java modularity in the UI space, RCP is the tool for you.

From a marketing point of view, this brings me to the same conclusion that Chris reached above. Basically, RCP needs to be rebranded as part of a suite of technologies related to Java modularity. In other words, RCP needs to become the Equinox UI.