Thing are quiet around here for the holidays, so I want to do another post on our Gwittir framework for GWT. In the last post I demonstrated some basic data binding and made a little Flickr browser. I am going to reuse a lot of the same technologies here and show you a little iPhone RSS reader. Yes, I know the GWT team did their own, but this is a nice example to show some of the differences, so you can compare and contrast. I also have a running example up.
I am using ROME on the server side again, this time with the OPML plugin
At my “day job” at Manheim Auctions we have been using GWT for a while now on “real world” projects. Along the way we have built a lot of tooling for GWT and we are now releasing a big chunk of it as Gwittir (like Glitter with a lisp). There are a number of tools included here, but the real core of it is made up of “lite” version of things you are accustomed to the the larger Java world. Here we will take a look at Beans Binding, and Animation to create a Flickr browser (running example at the link).
I kind of joke that this project is a roll up of a lot of the open source work I have done for the last couple years as it uses ROME and the MediaRSS module and is built with gwt-maven which I have talked about in this space before. You can grab the source for the example here. A long look at the code after the jump.
In the spirit of Neil and Josh/Will’s Java Puzzlers, here is one I just recently ran into:
Given the following block of code:
PropertyChangeSupport changes = new PropertyChangeSupport(this);
PropertyChangeListener l = new PropertyChangeListener(){
public void propertyChange(PropertyChangeEvent evt) {
throw new UnsupportedOperationException("Not supported yet.");
}
};
changes.addPropertyChangeListener("foo", l);
for( PropertyChangeListener remove : changes.getPropertyChangeListeners() ){
changes.removePropertyChangeListener(remove);
}
System.out.println(changes.getPropertyChangeListeners().length);
What will this snippet print:
- 0
- 1
- Throws an Exception
- Other
Answer after the jump.
A warning if anybody asks you about your job: the words ‘grabbing people’s brains and shoving them into a PC‘ is not the best explanation. I wouldn’t recommend explaining Rules and RuleFlow to your boss in those terms either. Unless they already think you’re some sort of Frankenstein and your name is Igor.
A better way might be to use the workflow example from the recent Irish Java Technologies conference. It show what Rules and Ruleflow are, in a way that even your boss can understand. And if your boss is the pointy-haired-dilbert-type, they don’t even need a computer to understand it.
The Health services in Bangladesh (like in many countries) can’t get enough doctors. Training more is not a solution ; those that do qualify often leave for better pay elsewhere. Given the desparate need for trained medical staff in rural areas, what are health workers to do?
The solution that the Health workers came up with was IMCI - or Integrated Management of Childhood Illness. It takes what the Knowledge in Doctor’s head’s and captures it as a simple guide that health workers can follow. When a sick child is brought into the remote clinic the health worker is able to follow the simple step-by-step instructions (like the to make quite a sophisticated diagnosis.
I’ve no medical training beyond simple CPR (and if you’re relying on that then you’re in real trouble) but even I can understand it.

Look at the pale blue box in the diagram above. It’s a set of medical rules: Are there any danger signs? What are the main symptoms? What combination of these symptoms are there? What is the age of the child? How long have they been ill? Depending on the outcome of the rules, go to the next set (the pink / yellow /green) boxes and apply the rules that you find there.
That’s Rules and RuleFlow.
- Rules are ‘when something is present , then do this’. And not just single rules, but many of them. Together, loads of simple rules allow you to come up with quite a sophisticated diagnosis.
- Ruleflow allows you to group your rules. If you’re a health worker with a sick child you want to do the most important checks first. Depending on the outcome, you then apply the next set of medical rules: Pink if they need urgent referral to the hospital, yellow if the clinic can cope , or green if the child can be looked after at home.
As gory as it sounds, everybody, including the doctors, are happy that their ‘brains have been put into a PC‘ (or in this case , a set of paper cards). The Doctors are happy because they can (guilt free) move to better paying jobs. The medical workers using the system are happy because they can help the sick children that they see every day. And the children gain because the better availability of medical knowledge (via Rules and RuleFlow) is literally the difference between life and death.
This article was orginally published on the JBoss Drools Blog. Paul also writes on People and Technology, explaining Enterprise Java using Pigeons.
There’s a quite interesting discussion in the blogosphere about proposed extension methods feature for Java 7. The problem tackled by this proposal is how to extend an API (interface) with new methods without breaking existing implementations. The example used in a discussion is a List
interface and the sort()
method. In order to add another method to the existing interface, Java developers today create static utility functions. Take for example the java.util.Collections
class, which is a set of static helper methods for working with collections. Among them is of course the aforementioned sort
method.