Leaving one of the greatest projects

This month is the last month in one of the greatest projects I worked. I’m leaving it with a crying and a smiling eye. The crying eye because I worked with so many great people and the smiling eye because I can see my family more often, especially at the moment.

This project was really great. For me it started two years ago with some meetings in Bonn, Germany. After building up knowledge I started traveling to Atlanta, USA with some colleagues and worked with a couple of great people that have done an amazing job. If one of these is reading this, they will know. After some month the project was getting more intense and I relocated to Atlanta, USA with other collegues and the time still was fun. Beside work there were a lot of evening barbecues and parties going on.

Now the real hard work started. I somehow got into the position of architecting and designing the client framework. During this time I met so many great people from US and India. We had a lot of fun working and playing Volleyball together. One of them now getting married and I wish him good luck and long life. Beside playing volleyball and calling every ball out which was quite funny because everyone knew it wasn’t out. He showed me some hints in planning and poker playing.

Also during this time we had a project lead with whom working wasn’t really enjoyable for some of us. Even I needed some time to get used too. But because he put a lot of pressure on us and played the role of the bad boy, I think we had so much success. Somehow everyone was convinced that he was the black sheep of the team. Everyone projected his bad experiences and failures on him but we as a team together worked really good.

Beside work I was getting used to the US more and more. At some point in time I changed my habbit. Instead of walking down the street to Starbucks or something else I took the car! At this time gas prices weren’t so high as they are now.

Our work environment also changed a lot during this time. But it was getting better and better. From an office without windows to a small room and conference room we finally worked in an office with windows.

During this time I also learned to play tennis and had a lot of fun playing with colleagues and in the Altanta K-Swiss Tennis League. Even if the tennis leasons are expensive with a private trainer they helped a lot and I got to play really good for the time I played. Often we played doubles on the weekend which was very interesting with different skill levels. In the first year I had two really good players with whom we played and they also showed me a lot of moves and gave me a lot of hints. For which I will be thankful. One went back to Czeck Republic and the other went playing golf. But I still played with collegues sometimes after work or on the weekend. During the after work play there were two collegues with really good skills. One had an amazing serve and the forehand of the other was unbeatable. In the US it is common to play on hard courts. That’s the reason US tennis players don’t play well on the European red clay courts. So how will I translate to the play on red clay?

In the second year there were a lot of changes. Members of the team left, new ones came in and the work was still challenging. Beside all sport activities I finally found some good clubs and bars for weekend parties. Because of this long time the team splitted up more and more over Atlanta but everyone still came together for a good barbecue.

Some even got more used to the US and bought cars, like Ford Mustang GT. They even needed a car for each family member, even the unborn. Or put a bid on ebay for certain special cars like the BMW Z9 which was only build one year and shown in the James Bond movie. I missed my chance for a yellow Honda S2000 which still bothers me. So I have to go with a German car.

During the second year the client framework was getting more and more stable and I got a deeper insight into Java Swing, JGoodies Libraries and certain extensions. Which helped a lot to finally change the framework into a direction to make it more usable and failure tolerant. In the end I think it works really well. As with everything I still have some features in mind which would make it the ultimate client framework.

Because the client framework was working so well, I got more involved into the business and worked with some great specialists in this field and beside work. Some took it even to the extreme in and outside of work and biked or dived areas where I would dream of.

You should leave when it is at the best, so you can keep the best memories. So beside being part of such a great project and having fun in the last two years, now is the time looking forward for new tasks and challenges.

Building up the framework

After the application displays an application frame and shuts down when the user closes the frame it is time to define the frameworks which are part of the application platform.

The application platform provides the JGoodies Forms, Binding and Validation libraries as part of the framework. Beside the core JGoodies libraries the application platform also provides extension like the SingleListSelectionUpdater described in an earlier post. It is an replacement of JGoodies Binding’s SingleListSelectionAdapter and can handle sorting and filtering in a table.

Also the application platform defines a framework for a form where the user views and edits domain objects. Common forms would be an editor form with input fields for attributes of the domain object or forms with lists which display a set of domain objects. From a design point these forms work on presentation models or list models. Forms are suposed to have no control logic except the propagation of text from input fields to domain objects. The control logic will be provided by another framework around different forms.

The control logic is provided by a page framework which provides the control logic executing operations on user requests through clicking a button, pressing an accelerator or hitting a keyboard shortcut.

Finally a JTreeTable

Finally someone at NetBeans has taken the time to write a real JTreeTable.

http://weblogs.java.net/blog/timboudreau/archive/2008/06/egads_an_actual.html

Swing’s JComboBox

The JComboBox in Java Swing can be used in two environments. The first is as normal component in a container and second as editor in a table, tree or list. In the first case every selection made in the list is propagated to the combo-box whereas in the second case it is only propagated when the popup is closed by pressing the enter key. Often the second behavior is better, especially when it comes to triggering a background task when the user finished the selection. There is already a bug in the Sun Bug database which discusses the correct behavior.

For uneditable combo-boxes it is easy to implement by simply overriding firePopupMenuCanceled(), firePopupMenuWillBecomeInvisible(), firePopupMenuWillBecomeInvisible() and fireActionPerformed(). Problems are starting when the combo-box is editable. In this case the editor didn’t update when the selection is finished. In the methods fire*Canceled() and fire*WillBecomeInvisibel() the property “JComboBox.isTableCellEditor” is set to Boolean.FALSE, in fire*WillBecomeVisible() this property is set to Boolean.TRUE to activate/deactivate the behavior when the popup is shown/hidden before delegating to the super implementation. In fireActionPerformed() the popup needs to be hidden after before delegating to the super implementation.

Now in an editable combo box when the popup is going to be hidden the method actionPerformed(ActionEvent) is invoked. I finally found this by searching some hours through the code. To solve the update problem I need access to the popup. But the BasicComboBoxUI doesn’t provide any method therefore.

public void actionPerformed(ActionEvent evt) {
  ui = (BasicComboBoxUI) getUI();
  try {
    Field popupField = BasicComboBoxUI.class.getDeclaredField("popup");
    popupField.setAccessible(true);
    ComboPopup popup = (ComboPopup) popupField.get(ui);
    int selectedIndex = popup.getList().getSelectedIndex();
    setSelectedIndex(selectedIndex);
  } catch (NoSuchFieldException e) {
    e.printStackTrace();
  } catch (IllegalAccessException e) {
    e.printStackTrace();
  } finally {
    super.actionPerformed(evt);
  }
}

This snippet accesses the protected field, retrieves the selected index from the list in the popup and updates the combo box with the selected index which also updates the editor and model.

This hacky solution makes it possible to solve the problem but is completely against any OO principle. Going further one can inject different popups and customize the combo box but it is still against information hiding and encapsulation.

Isn’t there a better solution???

Diätenerhöhung

Eine Erhöhung von 15 Prozent über 3 Jahre sind ungefähr 5 Prozent im Jahr. Wie hat Trichet nicht zum Anfang dieses Jahres gewarnt, dass eine erhöhte Lohnsteigerung in Deutschland für Europa nur zu einer erhöhten Inflation führen wird. Das würde die Inflationsspirale nur immer mehr antreiben. Durch die höheren Löhne die Produktionskosten ebenfalls wieder steigen, was zu einer Preissteigerung führt. Diese führt dann irgendwann wieder zu einer Lohnsteigerung. Jedenfalls haben unsere regierenden Politiker nichts weiter im Sinn, als mit gutem Beispiel voranzugehen und sich die Diäten um 5 Prozent zu erhöhen. Anstatt vielleicht aufgrund der aktuellen Situation eine geringere Erhöhung in Kauf zu nehmen. Vorerst könnten Diäten an einen Durchschnittswert gekoppelt sein, z.B. an die durchschnittlichen Löhne und Gehälter in Deutschland? Das lange Ziel sollte aber sein Deutschland zu einem unternehmerisch denkenden Staat umzubauen, bei dem es Lohn oder Gehalt auch für eine erfolgreiche Leistung gibt.

Background execution of long running operations

After showing some problems with the synchronous solutions like Foxtrot or Spin. Now I want to talk about Swing Application Framework’s TaskService or a small own solution.

The Swing Application Framework uses annotated methods which can be executed as during the actionPerformed() method of an Action. The method can return a task to indicate that it needs to be executed in the background. This Task object is handed over to the TaskService which executes it in a background thread, like a SwingWorker. The Task object might have a blocking scope that defines how much of the user interface is blocked during execution. This is quite easy and works very well.

My problem is the Task class which not only contains information about how to block, but also the responsibility to create the blocker and a reference to the task service. If there are multiple tasks it might be possible that two blockers show a dialog :-( . I would like to have a Task which is small and easy, like a command object from the command pattern. The command or task should then be handed over to the so called TaskService and this one should execute it.

First the Task needs to be simplified. Therefore the responsibility of creating and maintaining the InputBlocker moves over to the TaskService. The service has a single input blocker which is used in the complete application. So it has a unique interface and can also show a list of running tasks like the ProgressView of Eclipse. The service also should implement the Executor interface which makes it possible that even Runnable objects can be executed over this service. The service distinguishes between a Runnable object and a Task and can use a default blocking behavior like blocking the complete application. If the TaskService extends ThreadPoolExecutor it is easy to implement input blocking by blocking either in execute() or beforeExecute() and unblocking in afterExecute().

The Task class is then a simple extension of SwingWorker with some visual attributes like title and description, running time. An important BlockingScope that defines how much is blocked and an optional source from which the input blocker is able to block the user interface.

Background Execution

The image shows possible classes for the simplified service. I renamed the Task to SwingWorkerExt because it is a simple extension of SwingWorker. The enumeration BlockingScope and the interface InputBlocker stays as in the SwingApplicationFramework. But instead of having an association between InputBlocker and SwingWorkerExt, the input blocker only works together with the executor. In this case the SwingThreadPoolExecutor is the service used to execute background operations. introducing events when a command is added, removed, executed or rejected also helps the application to better react in extrem conditions.

Provider-Wechsel

Mit dem letzten Update von WordPress funktioniert auf meinem alten Provider das Schreiben von Artikeln nicht mehr. Selbst wenn ich das Update zurückrolle können keine Artikel mehr erstellt werden. Deswegen habe ich diesen Blog erstellt und werde mit der Zeit alle alten Artikel in diesen übernehmen. Bis auf weiteres wird hier weitergebloggt.

Freezing the user interface

Looking around for a good framework that encapsulates the user interface freeze problem in Swing I found Spin, Foxtrot and the Swing Application Framework’s Task framework. From executing the tests it seems that Spin and Foxtrot both have a problem on the Metal Look&Feel. The pressed button looks pressed as long as the mouse stays over it or doesn’t hit the boundaries and initiate a mouse entered or exited event. This mainly happens because the method blocks inside the actionPerformed until the background thread is finished. These frameworks reroute the Event-Dispatch-Thread (EDT) to a different event queue. The bug somehow doesn’t happen with the Windows Look&Feel.

Button with Spin

Button with Foxtrot

With the Swing Application Framework’s Task framework this doesn’t happen because the task will be sent to an executor service which executes it and the method returns immediately. There is no EDT rerouting or blocking involved.

Playing with Struts2

Weekends are supposed to be nice with sunshine and warm temperatures, not so in Atlanta! Over the last weeks every day during the week had plenty of sunshine. Only on weekends it started to rain.

So I started looking at Struts2. Because of the example application the first steps are quite simple. Starting a web application with Maven2 is no problem anymore. I got the application with a different model running in less than 2 hours (needed to write the domain objects and services to access them over the database).

But then it started getting more complicated. First I moved the datasource to the JNDI tree in Tomcat6 by replacing the data-source definition from Spring2.0 and moving it into the context.xml file for Tomcat. By doing this I also had to copy the JDBC driver over to Tomcats lib folder. Then I tried to bind the EntityManager or EntityManagerFactory to the JNDI tree. It seemed quite simple, simply add some elements to the web.xml descriptor. The Servlet 2.5 specification has some elements but Tomcat doesn’t recognize them. So I spent reading more than 3 hours and downloaded the sources for investigations. It doesn’t helped, Tomcat refuses these elements. So I went back to use Spring2.0 for the entity manager.

Now Spring2.5 is out (great, yeah, …). So upgrading should be as easy as changing some numbers in Mavens pom.xml. It’s just that spring-jpa is integrated into spring-orm and when using jee:jndi-lookup somehow Spring wants to use a JDBC transaction manager. So include spring-jdbc and everything works.

A nice thing I also got my hands in is Dojo because of the Ajax capability of the simple application. From a 10 minute view it looks like an interesting messaging system in a single web page.

But now that the weekend is close to be over, back to real work :-) .

Oracle TopLink goes Open Source

While searching for information on JPA I stumbled over the EclipseLink project. Which is the reference implementation for the upcoming JPA 2.0 specification. This seems quite interesting how Oracle distributes its classes. Because it is mainly the code base of Oracle TopLink. First it was part of the Oracle Application Server, then Oracle open sourced a small part of it called TopLink Essentials and it became a reference implementation for JPA 1.0. At this time I started to recognize TopLink as a valuable product. First it is much smaller than Hibernate and second it is the reference implementation. And now after reading that Oracle open sourced the complete TopLink product it will be a much more valuable product I’m gonna use :-) . Also the integration with the search library Compass makes it an even player to the combination of Hibernate and Hibernate Search.

When people at Eclipse also get the distribution of TopLink with Maven and people at TopLink the database integration (especially the sequence generator for PostgreSQL) done right. I’m going to advocate more and more the usage of TopLink.

Nächste Seite »