Rich Client Platform

What is a modular application, anyway?

August 27th, 2009  |  Published in OSGi, Rich Client Platform, eclipse

Drop of waterWhat does the term application mean in the context of modular software development (and OSGi in particular). It seems to me that the concept of an application starts to break down. For instance, is an OSGi application just the set of bundles known to the framework?

Well, here’s my take on what a modular application might mean.

Going beyond the steady state

When an OSGi framework fires up, some bundles may be activated, others may not. Some activators may perform logic, others may not. But what arises from this activity? Is this the equivalent of launching an application? It can be, but its more often the case that the framework arrives at a steady state, waiting for an input that triggers some behavior.

This can be confusing when we start using OSGi because this doesn’t look like an application. What we need is an entry point. Just as throwing a rock into a pond causes waves to form, we need to launch a thread of execution that takes us beyond the steady state. So how do we accomplish this?

Eclipse applications

The Eclipse platform provides us with one answer in the form of an Eclipse application. An Eclipse application is defined through the org.eclipse.core.runtime.applications extension point and is represented by an IApplication instance at runtime. And this mechanism can easily be added to Equinox by installing some additional bundles.

This is how, for example, Eclipse RCP applications are launched in the context of an OSGi framework. But it’s interesting to note that one set of bundles may support multiple applications. So a good way to look at an application is that it is merely a specific entry point into the functionality provided by a community of bundles.

The OSGi Application Admin service

We can take the concept of an OSGi application one step further by utilizing the OSGi Application Admin service. This service recognizes the concept of an application in the abstract (specific providers can define what an application means in each case), and allows an application to provide an entry point that will launch a thread of execution.

Equinox, for instance, provides an application descriptor for Eclipse applications. This means that you can use the Application Admin service to start and stop Eclipse applications from the OSGi console. The available console commands are:

  • apps – list currently available applications
  • activeApps – list currently active applications
  • startApp [app id] – start an application
  • stopApp [app id] – stop an application

These commands can be used to launch most types of Eclipse applications, including those with an SWT user interface. Unfortunately, they cannot yet be used to launch Eclipse RCP applications because of the way in which singletons are used. This is scheduled to be fixed as part of the e4 work.

Possibilities

I think all of this is pretty exciting because it allows us to reimagine the relationship between applications, modules and running platforms (JVMs and OSGi frameworks). For example, imagine being able to deploy an Eclipse RCP application into a running OSGi-based ESB. The application would allow you to manipulate the ESB in container and it could then be undeployed when no longer needed. All of this could be done without restarting the ESB.

It’s going to be fascinating to see how of all this plays out in the next few years. The possibilities are endless!

Adding Eclipse IDE menu options to your RCP applications

August 17th, 2009  |  Published in Rich Client Platform, Tips, eclipse

Note: The post below is actually incorrect, which is a good thing in my opinion. It is indeed possible to use the command framework to add the standard Eclipse IDE menu options. Rather than take down the post, which I think is unethical, please read the post and then the note at the end for clarification.

One of the many things that Eclipse RCP provides is a set of standard menu options that are used by the Eclipse IDE itself. These include standard menu options such as Exit, Save, Cut/Copy/Paste, but also workbench specific options such as Reset Perspective and Show Views.

In short, almost all of the menu options you see in the Eclipse IDE are available for use in your RCP applications. And I tell most teams starting out with Eclipse RCP to go through the Eclipse IDE menu and make a list of those options that make sense for their application.

So how can we add these menu options to our applications?

Using actions

Traditionally, Eclipse IDE menu options have been added as actions in the ActionBarAdvisor. The Eclipse actions can be referenced as constants in the ActionFactory class, and adding a menu option looks like this:

IAction saveAction = ActionFactory.SAVE.create(window);
fileMenu.add(saveAction)

Using commands

During the last few years, most Eclipse RCP developers have transitioned from actions to commands. Commands, and their associated handlers and menus, provide a clean separation between UI and non-UI concerns. As part of the transition to commands, Eclipse RCP now provides us with the Eclipse IDE menu options as a set of extensions defined in the org.eclipse.ui bundle.

command-extensions

The commands point to handlers that implement the behavior associated with menu options. We could, if we like, create org.eclipse.ui.menus extensions that refer directly to these commands. This would allow us to define our entire menu using declarative syntax.

Which approach should we use?

So the question is, should we choose the command-based approach? The answer (for Eclipse IDE menu options only) is no. Using the org.eclipse.ui.menus extension point to add Eclipse IDE menu options is problematic in that we lose access to look and feel attributes. Specifically, the ActionFactory constants provide us with the following menu attributes:

  • label
  • tooltip
  • image (enabled and disabled)
  • help context

Not only that, but the actions provide us with these values as externalized strings with support for internationalization. So while actions are really the old way of doing things, the ActionFactory/ActionBarAdvisor combo is still the preferred way of utilizing Eclipse IDE menu options.

When should I use commands?

Well you should definitely be using the command-based approach for your own menu options. Also the Eclipse IDE commands are still useful if you want to link your own menu options to them. You may want to reference the standard Eclipse IDE options in view menus, cheat sheets, dialogs, etc.

Finally, you should know that the actions produced by the ActionFactory are actually bridged to commands and handlers behind the scenes. This means that even though you are using actions to define the menu options, you can still provide your own handlers for them.

Clarification: What I missed when writing this post was that the Eclipse IDE commands contain localized text which will show up in your menu if you leave the menu label blank. Also, images will appear in the menu, and these are contributed via the org.eclipse.ui.commandImages extension point.

I’m still not clear on how tooltips or help contexts are handled, but you can get almost all the way there with the command framework. So in my opinion, the best practice for new Eclipse RCP applications would be to use the command framework for all menu options and discontinue usage of the ActionBarAdvisor.

Thanks to Lars Vogel for the correction!

Clarification #2: Having looked into this further, it appears that some of the standard Eclipse IDE menu options require that the ActionFactory action be created and registered before the commands will work. You don’t actually need to use the actions to create the menu options in the ActionBarAdvisor, though. For more information on this, see this Bugzilla entry.

Book Review: Practical Eclipse Rich Client Platform Projects

August 13th, 2009  |  Published in Rich Client Platform, eclipse, review

There aren’t many books available about the Eclipse Rich Client Platform. One reason for this, I think, is that it’s a difficult subject to cover effectively. Eclipse RCP is less a coherent framework than an aggregation of related technologies, and this can make it difficult to describe. As someone who has worked hard to craft clear Eclipse RCP training materials over the last few years, I sympathize with anyone who takes up the challenge.

And taking up this challenge is Vladimir Silva in his book Practical Eclipse Rich Client Platform Projects. I hadn’t heard much about this book, and only found about it when browsing the book table at last year’s EclipseCon. This summer I’ve finally found the time to read it and here is my review.

A good start

The first thing I like about the book is that it’s short. At a mere 335 pages, the book invites you to actually read it, not just treat it as reference material. I have a bias towards shorter technical books in general, as it shows a bit of self-discipline and thoughtfulness. The books produced by Pragmatic Programmers are a great example of this.

I also like the way the book starts, with a focus on OSGi. It’s essential that RCP developers learn from the start that OSGi and modularity are at the heart of the platform. Everything seems to click faster for developers when they understand some OSGi basics.

A strange mix

So far so good, but what is the rest of the book like? The word I’d use is odd. Any shorter technical book has to make tough choices about what to include, but the choices made by this author left me scratching my head a bit.

The first three chapters provide a pretty thin introduction to the structure of an RCP application. Topics covered include the workbench, editors, views, menus, commands, handlers and product branding. But all of these topics are covered extremely briefly and in my opinion do not add a lot to what can be found in the Eclipse help system.

After that, the book gets more interesting, but in an odd way. The author takes us on some deep dives into an eclectic mix of advanced topics (with the exception of a chapter on the help system). These topics include:

  • Common Navigator Framework
  • 2D graphics with GEF and ZEST
  • 3D graphics for RCP with OpenGL
  • BIRT
  • Automatic updates

These topics are covered in various levels of detail. The chapter on OpenGL, for instance, is as long as all of the RCP chapters combined!

My initial reaction to this content is that if you’re interested in some of these topics, then this book is worth buying. There is very little published content on topics such as CNF and Zest. But in the end, I think these these topics are only tangentially related to Eclipse RCP itself.

Final thoughts

There are so few books on Eclipse RCP that any book at all is a welcome addition. And I applaud the author for covering some topics that have received so little attention in the past.

My overall recommendation is that if you’re looking for a solid introduction to Eclipse RCP, this book is not really for you. My suggestion would be to pick up Eclipse Plug-ins, which covers the core Eclipse RCP APIs much more thoroughly.

On the other hand, if you’re an Eclipse RCP developer interested in one or more of the topics covered in later chapters, definitely have a look.

Introducing Modular Mind

August 11th, 2009  |  Published in Announcement, Rich Client Platform, eclipse

My personal journey with the Eclipse Rich Client Platform began 6 years ago. I was starting work on a financial analysis application, and was looking for a cross-platform framework to build upon. Eclipse was my IDE, and I began to see some interesting Bugzilla entries that pointed me to what would become Eclipse RCP.

Like many, I was originally attracted to Eclipse RCP because it promised to shorten my development cycle. It gave me a workbench, perspectives, editors, views, wizards and much more. And you know what, it worked! I did develop an application that would have been impossible to create without such a framework.

But while working on that application and in my subsequent work on other projects, I’ve come to appreciate that Eclipse RCP is not a normal framework. Much of its power comes from its support for creating modular user interfaces. The ability to flexibly assemble and package user interfaces has opened up many possibilities for myself and my clients.

And I’m not talking about geeky development-type benefits here. Modularity allows us to create (or assemble) applications that are more targeted to the specific needs of users. In short, modularity makes software more useful. Modularity also allows us to approach software licensing and marketing in ways that were not possible before. In the end, modularity can result in a significant competitive advantage.

And now that I’ve finally come to see modular software development in this way, I’ve decided to make it the focus of my training and consulting practice. I’ve renamed my blog (and my company) Modular Mind. I’ll still be focusing on Eclipse RCP and OSGi training, but in the broader context of modular software development. I can’t wait to see what the next 6 years will bring. If they’re anything like the last 6 years, this is going to be a lot of fun!

Note: As part of my broader focus, I’ll be writing posts which will no longer be aggregated on Planet Eclipse. If you’d be interested in reading these posts, you may want to subscribe to my feed directly.

Renaming Eclipse RCP – Update

July 22nd, 2009  |  Published in Announcement, Rich Client Platform

It’s been two months since my post requesting that we rename Eclipse RCP, and I thought it was time to provide a progress update. The response has been overwhelmingly positive. Check out the comments on the original post as well as the discussion associated with the Bugzilla entry, and you’ll see what I mean.

So where are we right now?

First, there is a consensus that the renaming should apply only to the new version based on e4. Past versions and also future 3.x releases will continue to be referred to as Eclipse RCP.

It has also been expressed that the name should be chosen as quickly as possible so that it can be used for early milestone releases. I would prefer to see a name selected in the next month or two.

What next?

Do you have ideas for a name? An initial set of names has been captured on a wiki page, but it would be great if we had some more ideas. I know it’s the middle of summer, but that can bring out the creativity in some people! When you’re lying on the beach, why not spend a few minutes thinking about this. Who knows what you might come up with!

I’m particularly interested in names that reflect the fact that RCP brings modularity to the user interface. If you think of anything, you can either add it to the wiki directly, comment on the Bugzilla entry, or comment on this post. I’ll make sure that all suggestions make it into the final list.

In a few weeks, I’ll put together an online poll that will hopefully result in a short list of names (please do not tell Stephen Colbert). I’m sure other factors will be considered as well (trademarks, etc), but the poll will be an important part of the final selection.

I can’t wait to see what we come up with!

Logging RCP applications with Pax Logging

July 14th, 2009  |  Published in Rich Client Platform, Tutorial

Adding logging to an RCP application has always been painful. Developers have struggled with the best way to incorporate Log4J and other logging APIs, and in particular with how to make configuration files accessible. Some have chosen to use buddy classloading, others have utilized fragments containing the config files.

Pax Logging to the rescue

I’m happy to say that RCP developers now have another choice - Pax Logging. There are a few great things about this library:

  • Installation is easy. I’ll describe this in a bit.
  • Configuration files can be placed in regular folders, either inside of an application bundle or anywhere on a users machine.
  • Many logging APIs are supported, including Log4J, Commons Logging, JDK Logging, SLF4J and more. This means that legacy and third-party code can run as-is no matter what logging API they use.

Logging configuration with Pax ConfMan

Because Pax Logging requires the OSGi Configuration Admin service to work, your first step is to install this service in the form of Pax ConfMan. In my last blog post I provided detailed instructions on how to do this.

Adding configuration settings

The good news is that once you install Pax ConfMan, you’re almost done! Pax ConfMan requires the Pax Logging bundles in order to work, so we only have a few minor steps left.

The first is to add a logging configuration file. When using the OSGi Configuration Admin service, services are identified using a persistent identifier, or PID. Developers can choose the PIDs for their own services, and an implementation of the Config Admin uses these PIDs to inject properties into services.

Pax ConfMan does this by requiring that a properties file be named based on the PID of the service it is going to configure. For example, the Pax Logging PID is org.ops4j.pax.logging and so the properties file for this service will be called org.ops4j.pax.logging.properties.

If you created the folder structure suggested in the Pax ConfMan setup, simply create a file called org.ops4j.pax.logging.properties in the confadmin/services directory. You can now place whatever logging configuration you like into this file. For instance, here’s what I have for my simple test project:

log4j.rootLogger=DEBUG, A1

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

log4j.logger.com.rcpquickstart.logtest=DEBUG

Forcing Pax Logging to start

Just as we did with Pax ConfMan, its necessary to force Pax Logging to start up when our application is launched. To do this, we simply need add the org.ops4j.pax.logging.pax-logging-service bundle to the Configuration page of the Product Configuration Editor and set it’s Auto-Start property to true. If you’ve followed the instructions for installing Pax ConfMan, your complete list should look like this:

paxlogging-1

Fire it up

That’s all there is to it. Start up your RCP application and you should see log messages appear in your console.

paxlogging-2

Happy logging!

Let's rename Eclipse RCP

May 26th, 2009  |  Published in Ramblings, Rich Client Platform

I love Eclipse RCP. I’ve devoted the last 6 years of my life to developing with RCP as well as teaching it to others. In my opinion it’s one of the most important (and underused) technologies for developing UI applications. Having said all that, the name is horrible and it’s time to change it.

My preference would be to rename Eclipse RCP as part of the Eclipse 4.0 release. There are few times in the life of a project when it changes enough to merit a new name, and for Eclipse RCP this will be one of those times. The work being done as part of the e4 project represents a significant evolution of the platform and will make it useful to a far larger audience. A new name (and branding) will go a long way to encourage the adoption of this technology.

If this approach was taken, we would have a year to select a new name and marketing approach. This post is a bit long, but here is where I would start.

RCP is the user interface of OSGi

The adoption curve for OSGi is turning up and developers are quickly coming to see the benefits of modular architectures. Eclipse RCP is perfectly placed to serve as the UI layer for modular software. The name and branding for RCP should reflect this focus on modularity and on its close relationship to OSGi.

I’ve seen a number of projects switch from RCP to Flex because the decision-makers thought they were choosing between two UI toolkits. They were really deciding between a UI toolkit (Flex) and a modular application framework (RCP). This is a problem.

RCP is moving beyond rich clients

When Eclipse 4.0 is released RCP will be much more than a tool for creating rich client applications. RCP and RAP are converging and there should be common naming scheme that unites them. One approach would be to have a base name for the technology that takes a modifier for each targeted architecture, something like “X Web” and “X RC”.

To use “Eclipse” in the name or not

This is a general issue with Eclipse projects. There is always a tension when a set of projects evolves around a spectacularly successful product. On the one hand, it can be beneficial to leverage the success of that product to promote other projects. But it can also lead to a great deal of confusion, and this is particularly true with Eclipse RCP.

To make this work well requires a rigorous approach to project naming and marketing so that the benefits of name recognition are not overwhelmed by a lack of clarity. In my opinion, the best example of this is the job done by the Apache Foundation. While the Apache HTTP server still exists, the word Apache has been successfully rebranded to apply to a whole host of projects. Each of those projects is uniformly named Apache X and benefits from this association.

The Eclipse Foundation has, unfortunately, not done as good a job. Eclipse is still, well, Eclipse. Most developers assume that other Eclipse Foundation projects are somehow related to the IDE and therefore unapplicable to their use cases. Individual projects are named in a wide variety of ways, sometimes using the Eclipse name (Eclipse RCP), sometimes not (BIRT), and sometimes using it as part of an acronym (EMF). Taken as a whole, the project names in the Eclipse ecosystem are extremely confusing.

On a side note (and I’m sure this is a minority opinion), I think that the umbrella names for the release train (Europa, Galileo, etc.) reinforce the idea that Eclipse (and all of it’s projects) are about the IDE.

In any case, to successfully use the Eclipse name the following two things would need to occur:

  1. The adoption of a common naming scheme “Eclipse X” for all projects.
  2. The application of this scheme to Eclipse itself (e.g. Eclipse Workbench)

Without this approach, my opinion is that using the Eclipse name in association with a rebranded RCP is not a good option. My vote would be for a stand-alone name.

Getting started

So much work and thought is going into e4 and there is enormous potential here. Let’s give this technology the name and branding that it needs to reach a wide audience.

I’ve purposely shied away from suggesting names here, but I’ve cross-posted to a Bugzilla entry where potential names can be discussed.

Note: If you agree with this post, please consider commenting on the Bugzilla entry (even a “+1″ would help).

Thoughts on Eclipse RCP Training

April 5th, 2009  |  Published in Announcement, Rich Client Platform

At EclipseCon I had the opportunity to sit down with Wayne Beaton and record a podcast on Eclipse RCP training. It’s really not a sales pitch kind of thing, more of a discussion of the challenges faced by developers new to RCP.

But after we finished recording, it occurred to me that I’ve never really expressed what I feel the value of Eclipse RCP training is. It’s common for developers to approach me and say “I know I need RCP training, but how do I justify this to my manager?” Well for those of you in this situation, here is what I would say.

Time is money

The first argument is a purely financial one. It’s just a fact that acquiring knowledge takes time and effort. If you spend days or weeks at your desk assembling information on RCP from websites, articles and books, then your salary during this time is the cost of knowledge. The question is, how does this approach compare with learning from an instructor?

According to many of my students, learning RCP in a classroom is much more effective. There are a variety of reasons for this, which I’ll get to in a minute. But it seems to be true for most people that training significantly shortens the RCP learning curve. I’ve taught many classes over the past few years, and based on student feedback I’d say that RCP training often pays for itself in weeks, not months.

RCP is hard to learn

One of the main reasons RCP training is so effective is that the subject area is complicated. Unlike other technologies, RCP is not standards-based, so there is no canonical spec you can go to for answers. To be honest, RCP is less a coherent framework than an aggregation of related technologies (SWT, JFace, OSGi, Eclipse Platform).

The problem for someone learning RCP is where to start and how to acquire knowledge in a coherent and orderly way. What RCP training does (if it’s done well) is to cut through the noise and present a clear vision of what RCP is and how to use it.

Getting a team up to speed

Oftentimes RCP is introduced to a team by a self-taught lead developer who evangelizes the technology. When the decision is made to use RCP, the lead developer is often called upon to share his knowledge with the rest of the team.

The problem is that most developers are not (and do not want to be) teachers. Creating carefully designed presentations and labs is difficult. Communicating the information clearly to students with a variety of backgrounds and learning styles is even more difficult.

The real magic to being a good teacher is to remember what it was like to not know something. This might sound like a zen koan, but it’s really just another way of describing empathy. If you find a good trainer, I think you’ll be impressed by what this magic can accomplish.

Why can’t I just read a book?

This is a really good question. It’s obviously true that some people can learn RCP by reading books. That’s how I learned. But a better question is could you learn more effectively through a training course?

I’d argue that a training courses is more effective than books for a number of reason. First, students have a variety of learning styles. Some learn by hearing, some by seeing, some by doing, most from a combination of all of these. Only a training course can communicate information in all of these ways. Second, a multi-day training course appears to function something like immersion-learning for a foreign language. While people usually read books a bit at a time, there is a distinct advantage to focusing all or your mental energy on a subject for 3-4 days straight.

Speaking empirically, I’ve had more than a few students tell me that they’ve read books but that things didn’t click until they took the course. Whatever this click is, it appears to be what students need to get started working productively with RCP.

Making sense of e4

March 30th, 2009  |  Published in Rich Client Platform

There was so much going on at EclipseCon last week that I have to admit my head is still spinning. I’m trying to get back to work, but my mind keeps turning to the people I met and the sessions I attended.

One area I really wanted to get into at EclipseCon was e4, which is the project that is attempting to redefine the Eclipse platform. The work being done is varied and fascinating, and I’ve been trying to figure out what it all means at a high-level. Well from what I’ve learned so far, the two main focuses of e4 are flexibility and simplicity.

Flexibility

The platform is becoming more flexible in so many ways, it would be hard to list them all. But here are a few examples:

  • Internal structure of workbench window is up to you. Use perspectives or not. Embed parts in other parts, etc.
  • Much stronger styling support using style sheets.
  • Ability to create widgets and parts using different toolkits and even different languages.

One thing is clear – e4 is going to drastically increase our options when developing RCP applications.

Simplicity

The platform is becoming simpler in that the platform framework is being broken down into smaller and more uniform APIs that are loosely coupled to each other. Examples of this are:

  • Increased focus on POJOs throughout the various APIs.
  • Decoupling of APIs through contexts and dependency injection.

I really do think that it will be easier to develop RCP applications after these changes are made. Hopefully it will make my job as an RCP trainer easier too!

The conflict between flexibility and simplicity

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

Sir Charles Anthony Richard Hoare

What’s interesting is that flexibility and simplicity are usually in conflict. In framework design, we usually trade flexibility for simplicity and vice-versa. So how will the e4 team pull this off?

The answer lies in the idea of insightful simplicity. There are many types of simplicity, and some are not at all useful to software developers. But insightful simplicity arises when a team has lived with and understands a domain so thoroughly that they start to see the problem space in an entirely new way. Insightful simplicity can result in architectures that are not only simpler but that dramatically increase flexibility, enabling developers to create entirely new types of applications.

Insightful simplicity usually arises only after an initial framework has been created and evolved for an extended period of time. Frameworks tend to expand and get more complex as new use cases are incorporated, but eventually there comes a point when a team starts to see how the entire thing can be collapsed and simplified. This is where we’re at with the Eclipse platform, and the e4 team is now taking this insight and turning it into a reality.

Personally, I can’t wait to see what going to happen when developers get a hold of this technology. It’s going to be amazing!

Real World RCP at EclipseCon

March 10th, 2009  |  Published in Announcement, Rich Client Platform

In my opinion, one of the best ways to learn about a technology is to listen to people talk about their own projects. Developers who have been in the trenches and worked through the nitty-gritty day-to-day issues have so much to teach us and can save us a lot of time and effort.

If you agree, I hope you’ll consider attending the Real World RCP session at this year’s EclipseCon. If you do attend, you’ll hear 4 developers talk about some extremely interesting RCP usage scenarios, including earthquake damage simulation and nuclear plant testing. You’ll also hear about how RCP can be combined with a variety of other technologies, including CNF, EMF, and GEF to solve real-world problems.

So stop by Wednesday morning! If you’re currently working with RCP or evaluating it for a future project, I think this session will be worth your time.