I have been continuing my work on integrating Beans Binding (JSR 295) and the Swing Application Framework (JSR 296) with the work I have been doing on providing a JPA enabled HMVC framework for Swing developers. I must already say that getting to the information on how to exactly use these two apis isn’t straight forward. JavaDoc is probably not what it should be. I can’t really blame them on this, as I am probably the worst candidate for this exercise. Document, as in RTFM, is completely nonexistent.
As I was coding on some UI parts of the demo application for this, I got mail about the issue I mentioned earlier with the NetBeans example code. It seems either the Beans Binding stuff (more specifically its ObservableList implementation) has issues dealing with the same elements being removed and added back again to the Collection.
Indeed, I was executing a Query on the EntityManager returning the same Set of instances (as the EntityManager will take care of Object Identity for you), but this seems to break some bindings (NPE). I could figure out why yet though! I didn’t got it first, as the mail stated that this behavior was not reproducible with the initial transaction management, as generated by NetBeans. But then it came clear, as I was reverting the changes, that the RefreshTask was rollbacking the transaction, causing managed instances to become detached and the Query hence returning new object instances for every row from the table.
I fixed this for now by calling a EntityManager.clear() while doing the refresh. I think this is pretty ugly, as I would expect object identity to be something I want to be able to rely on, especially in such long living applications as Swing rich client apps.
Bad news is that I found about a downside of my approach. But I guess this is probably more related to me trying to fix a inherently broken example…
That’s it JavaPolis is over. It was a great success again and completely sold out weeks before it actually began… It was a great opportunity for me to catch up with old friends and time to make some new. The French speaking community was pretty present and I was really pleased to chat with people I had not seen since the Sun Tech Days in Paris in February.
Bruce Eckel tried to introduced the Open Space concept to the event this year. While I haven’t had a chance to participate in any of the round tables, I think it was pretty quiet on that side of the venue… Sad, as the CITCON in Brussels, which was my actual first unconference, has convinced me completely of the format!
Other highlights for me of this year’s conference would have been the BOFs on Closures and future language features that might (or not) be introduced. Joshua Bloch changed his actual conference slot last minute for “The Closure Controversy”. And I am part of the people that have changed their mind in favor of not introducing these in language after all. This session would probably have made the conference for me, even if it would have been the only session I had attended.
During a less interesting keynote (for me at least), I decided to launch NetBeans 6 that I installed ever since it was released, but yet had no chance to look at. One thing that NetBeans got really strong in, would be GUI. I remember getting Matisse demoed a few years back in San Francisco. While I might not give up on IntelliJ Idea any time soon, I still like to have a look at every new major release. So the first thing I did after it launched, was creating a JSR 295 / 296 application. I couldn’t resist to go for the database one, using JPA.
I remember Hans Muller’s session during last year’s JavaPolis, where during a demo I saw some weird code about transaction management. As soon as the project was setup, I had to realize that this transaction management made it in NetBeans example code! Besides the fact that every client would have a long living transaction on the database back-end, which probably wouldn’t be what you’d want on production sites, this kind of transaction management can lead to weird behaviors.
As I was sitting next to Vincent Brabant, I quickly added a button to the UI to generate a Query that would force the EntityManager to flush changes to the database, while the user would not yet have decided on whether he wanted his changes to be persisted. On top of that pressing the generated Refresh button would make the behavior of the application even more confusing to the user… I used that to demonstrate my point to Vincent. Provided an alternative implementation that solve this issues and have him provide feedback to whom ever might help on this.
On my other side was sitting a colleague of mine, he quickly also discovered by looking over my shoulder, as he is much more of a Swing expert than I am, that Tasks were accessing Swing components from another thread than the EDT. That all left me with a weird first opinion on NetBeans 6! I really believe Sun should try to put more effort on providing meaningful example code to developers. Especially junior ones! It is so easy to screw people’s mind up… Swing and the EDT are so misunderstood by many developers out there. It would be important to communicate better around this stuff. Same is true for JPA! Hibernate is probably the most misunderstood, yet widely used, tool out there. It would be nice if JPA developer could try to avoid picking up on these bad habits.
So after a week full of great informal chats and technology show cases, I got back to work. Not had much time to do anything useful, still I managed to think a bit. While I am still in the process of completely rewriting the Hibernate implementation of my “distributed JPA” tool before releasing it, I also try to correlate what the Sun guys have done with JSR 295 & 296 with the stuff I have been doing on HMVC with JPA for Swing apps.
I hope I will finally be releasing my work on Distributed JPA entities by the end of my holidays, within two weeks that is. I’ll then do my best to get something going this Swing “framework” thingy.
Another demo at JavaPolis by François Orsini and Jean-François Arcand on JavaDB and Comet got me inspired for a nice proof of concept for all these thing. Hopefully I’ll be able to tell more soon. But even if I cannot get to put all the effort I would like to into it, some other guy I spend the night with in back in Brussels after JavaPolis offered to have a look into it as soon as I get more on it done…
So cool stuff for this season’s coding! This will be a pretty full two weeks of holidays. Hopefully my daughters let me get to some coding…
Just downloading developer preview 8 from the ADC Member Site. Apple just made my day!