Sunday, June 7, 2009

Book Review: Spring Web Flow 2 Web Development

Spring Web Flow 2 Web Development by Sven Lüppken and Markus Stäuble is the currently only available book on Spring Web Flow 2.0. The book covers all the components that are part of the Spring Web Flow distribution such as:
  • Spring Web Flow
  • Spring Faces
  • Spring JavaScript
Additionally, the book also provides an overview of Spring Security. The book comes with example code for many of the chapters.

The provided examples, however, could have been a little more consistent. The main source example in this book is covered in chapter 5 (A simple bug tracker). I liked the given example, as it does not require a database. This makes it easy to understand the Spring Web Flow specific problem domain. However, considering the fact that the authors also talk about Spring Security in other chapters, it would have been nice, if they had used the bug tracker example throughout the book in order to create a “complete” application, that ties together Spring Web Flow, the persistence layer and Spring Security. Unfortunately, the code examples given in later chapters don't refer back to the bug tracker example. Instead, chapter 6, for example, uses a shopping cart example.

A further minor annoyance is that the source code for 2 of the chapters still contain the eclipse project files used by the authors. This may be confusing for some users as these project files still point to Microsoft SQL Server drivers on a windows D: drive. I, for instance, use a Mac...

In chapter 2 the book discusses on 4 pages Ant and Maven. I think it might have been simpler for the understanding of the book and the provided source code, if only one build system was used, e.g. Maven. Some of the code examples provide Ant and Maven build scripts but some other ones provide support for Maven, only.

Another anomaly was, that the book describes the installation of the Spring IDE plugins for Netbeans and Eclipse on 7 pages but then the authors mention in passing only that they are using Microsoft SQL Server as underlying persistence store for their example. As many Java developers may not have a MS SQL Server license, it may have been better to use open-source Databases such as MySQL or PostgreSQL.

The example in Chapter 3 uses HSQLDB for its database but earlier (Chapter 2) the authors use MS SQL Server. For consistency and simplicity reasons the book could have stuck with one database.

Chapter 4 deals with Spring Faces. The authors should have mentioned JBoss Seam, since Seam solves a similar problem as Spring Web Flow but having a default focus on JSF.

The book provides an entire chapter on JSF integration (Chapter 4). As JSF is a widely used framework and Spring Weblow provides native support for JSF. It would have been nice though, if support for other frameworks such as Struts 1 and 2 would have been illuminated.

As part of chapter 5, the book also provides information on Spring JavaScript. While it is part of the official Spring Web Flow distribution it is not necessarily essential for the working of Spring Web Flow and even its spec lead Keith Donald mentioned at the Atlanta Java Users Group (AJUG) meeting in November'08 that it maybe extracted into its own project in the future.

The section in chapter 5 which starts on page 165, the Web Flow Configuration, felt repetitive to parts of Chapter 3 (pages 53) and should have probably merged with that section. Chapter 5 also contains a larger section on Apache Tiles integration. One thing that I did not understand was how Tiles matters in terms of mastering Spring Web Flow. Generally I don't mind explaining additional pieces of information around the edges of your problem domain but if that happens on 5 percent of the book, it needs to matter within the context of the targeted subject. On a site-note: Take a look at SiteMesh for your templating needs. I strongly prefer it compared to Tiles.

In chapter 6 the testing of your Spring Web Flows is explained. This was an informative chapter and I particularly liked mentioning of EasyMock.

In chapter 7 the book primarily details Spring Security. In my opinion, it provides too much Spring Security centric information. For example, the chapter describes how to create and write your own AccessDecisionVoter. In my opinion it does not help and is unnecessary for the understanding of Spring Web Flow. At most I would have chosen an example that uses a DB-backed security implementation using default Spring Security functionality.

To me, chapter 7 was a bit strange. It provides 16 pages of information introducing Spring Security but the actual integration of Spring Web Flow with Spring Security is accomplished in merely 4 pages. Most interestingly, that's where the book simply ends. I missed something like a wrap-up, that summarizes what the book covered and where to continue on.

In Appendix B the authors provide an overview of Springsource's dm Server. Personally, I think that dm Server is an interesting offering. However, I don't understand why this appendix even exists in this book. It is neither important for the understanding of Spring Web Flow, nor do the authors explain why this appendix exists.

Here are some further thoughts: Throughout the book, I like the use of Maven for building the examples. It certainly makes it easy to understand the examples' structure.

I think for the understanding of Spring Web Flow, it unnecessarily complicates things, if you present examples that require JNDI for establishing database connectivity. Furthermore it binds you to a concrete application server, which in this case is Tomcat.

Except for a for a very brief mentioning on page 224, the book never talked about the applicability of Spring Web Flow in the context of RIA frameworks such as GWT, Flex etc. Is there a use case for Spring Web Flow e.g. for coarse grained server state for large, complex applications?

It would have been nice if the book provided an overview of other frameworks that handle conversational state such as JBoss Seam. Additionally, since the books was published in March 2009, it could have described some of the planned conversational state management support planned for Spring 3.0.

Furthermore, it would have been great if the book had also mentioned how Terracotta can be used to back Spring Web Flow conversations. Terracotta provides an interesting reference application detailing that possibility.

Anyway, the book follows generally the Spring Web Flow documentation. The question is how much more value does the book add compared to the reference documentation. Overall, I have a quite conflicted opinion about this book. I think, if you are interesting in JSF integration or the bulk of the additionally discussed technologies (E.g. Spring JavaScript), then this book may add enough information for you. It certainly provides some useful information regarding Spring Web Flow 2.0.

Unfortunately, it contains quite a few inconsistencies and it is overall not an easy read. However, it is the only currently available book dealing with Spring Webflow 2.0. On Amazon, I gave the book 2 out of 5 stars.

Wednesday, June 3, 2009

Book Review: Learning Flex 3

Learning Flex 3 by Alaric Cole is a great introductory book for Adobe Flex 3. If you have some basic experience with HTML, JavaScript and CSS, then you will learn the basics of Flex rapidly using this book as a guide. Some of the areas that are taught are:
However, if your professional background is in web-application development using Java or other OO languages, then you are probably more likely to skip or cross-read sections of the book. This is because the book starts out with practically no initial pre-requirements, and thus you might be familiar with some of the discussed areas.

The book gave me an excellent overview of Flex's capabilities, and they are all explained thoroughly and are easily understandable. Also, this may sound silly, but I particularly liked the refreshing fact that the book is in color, unlike most other IT books.

Furthermore, the book explained Data Binding (Chapter 7) very well. This is something I was not familiar with coming from the Java world. The chapter illustrates the concepts of one-way binding, two-way binding and making your own variables “bindable” using a metadata declaration, which is basically an annotation in Java parlance.

Another feature I liked a lot was View States (Chapter 12), which allows you to rearrange, group and reuse components within your application.

I wish the book provided more information for further reading. I understand that certain concepts are beyond the scope of this book, but it would have been nice if those had been mentioned and links or recommendations for further reading were provided.

For example, while AMF is mentioned on page 8 and on page 157 the book briefly talks about the Webservice and RemoteObject component, the book should have also mentioned BlazeDS as one of Flex's core technologies for communicating with back-end servers.

And for more complex applications, the book could have at least pointed out some of the available MVC frameworks for Flex and some pointers of where to read more about them (E.g. Cairngorm and PureMVC). Well, and then there is Degrafa, the declarative graphics framework…

While the author explains the aspects of using CSS in Flex applications very well, he could have further stressed that Flex uses a subset of CSS, which in certain areas behaves differently compared to CSS you more typically use in HTML pages. He should have enumerated some of those pitfalls.

Having said all this, these issues mentioned above are minor in nature. Overall, the book was a fun read! And particularly to Java web-developers, Flex may very well be THE contender for application user interfaces moving forward. One of the great things about Flex is that even the standard components look very good (and should be good enough to please your boss), and your application looks and behaves consistently across various browsers. Oh, and yes you can run the same application on the desktop as well (Chapter 15).

This book will definitely help you learn and master Flex, and you should be able to produce functional user interfaces quickly. In order to learn more about integrating Flex with your Spring powered back-end you may want to also consider looking at “Pro Flex on Spring”.

Thursday, May 14, 2009

JavaRebel + m2eclipse = Sweet Spot

One of the pain-points while developing Java-based web-applications is the issue of the bouncing server. Every time you change a class file, your web application context needs a restart. While this is mildly annoying for small applications, it is simply unbearable for anything more substantial.

As far as I now the best and cheapest solution so far has been to use MyEclipse. It worked great and I rarely had to restart web contexts.

I always wondered why the standard IDEs (E.g. plain Eclipse WTP, IntelliJ ) never solved that re-deployment issue. Well, at least I have not been able to get this sufficiently working in plain Eclipse+WTP or IDEA IntelliJ.

Unfortunately, with the advent of Maven, MyEclipse started to loose come of its charm. For years, they were not able to provide an acceptable Maven integration (There was an entry on their forum for years demanding that feature) and on the other side, WTP started to become usable (I have not really tested the Maven integration introduced with MyEclipse 7 but I have read, that it is still not perfect). But one thing, that MyEclipse had nonetheless going for it, were its hot deployment capabilities.

Enter ZeroTurnaround's JavaRebel. Four weeks ago I started looking at JavaRebel and have been using it for the development of my OSS project since then. My verdict: It is awesome.

I use it in conjunction with the m2eclipse plugin and it simply works. ZeroTurnaround provides guides regarding the Eclipse and Maven integration (here and here) that are fairly straigtforward. It also comes with support for Spring and Struts2 directly.

The nice thing about JavaRebel is that it is agnostic to the used IDE as it simply hooks into the JVM as a Java agent. Therefore, you probably could also easily use it from the command line (in case you like to code using VI :-).

One drawback is the price which makes JavaRebel more expensive than MyEclipse. On the other hand, there is not much in MyEclipse that you cannot have in plain Eclipse/WTP using free plugins. Thus, ultimately it may boil down to personal preference but to me JavaRebel with plain Eclipse WTP (or IntelliJ for that matter) is the much nicer package. And if you have a project with an OSS license you can get JavaRebel for free, and don't have to buy MyEclipse.

Friday, May 8, 2009

Vi on a fresh Ubuntu installation - issue

I am in the process of setting up Ubuntu 9.04 on my Linode instance. Looks like Vi was behaving screwy (Keys did not work as expected). Luckily there is Google and the following link helped.

I created a .vimrc file in my home directory:

vi ~/.vimrc

and added the following line to it:

set nocompatible

That worked for me.

Tuesday, April 28, 2009

Postfix relay messages to different port

A frequent occurrence in applications is to send out emails. In order to test that behavior sufficiently during development, I usually use one of two options. On Windows you can use Mailster (preferred) or you can use postfix etc. on Mac/Linux (Have not been able to get Mailster going on my Mac)

So far on my Mac until recently it was as easy as to simply do: sudo postfix start and I was good to go. Unfortunately, my domain hoster does not accept mail on port 25 anymore. And the simple relay stopped working.

As it turns out though, you can easily relay to a different port (My hoster accepts port 26):

sudo vi /etc/postfix/main.cf
I added a line (near # INTERNET OR INTRANET):

relayhost = myHost.com:26

And finally I reloaded my postfix configuration using sudo postfix reload and I was back in business once again.

Wednesday, April 1, 2009

Woes with Oracle's Jdbc Driver and BigDecimal

As other people before me noticed, Oracle seems to have issues with BigDecimals. Well, I hit one of those issues today:
  • BigDecimal.valueOf(0.000000548) became 0.000000538 in the database
  • new BigDecimal("0.000000548") became 0.000000538 in the database
  • persisting a plain String "0.000000548" worked fine however
  • new BigDecimal("0.000000458") became 0.000000448 in the database
The table column, to which the values were saved, had plenty of "scale'n'precision".
The issue occurred in Oracle's JDBC driver version 10.2.0.1.0. Luckily, after upgrading the drivers to version 10.2.0.4.0 the problems went away.

This is by itself an amazing issue - Just imagine, you were running a larger financial app. You may not even notice this subtle issue until your app is long in production. Oh well...

Saturday, March 28, 2009

DevNexus Report Part 2

In part one I provided an overview of attended DevNexus sessions. Here are some more details I took away from the presentations. The first days of the conference started out with Neil Ford, who always seems to provide those excellent but more high-level-off-the-beaten-path-type presentations (The presentation certainly contained an interesting Angelina Jolie picture). In his presentation he talked mainly about a quality work environment and how to be more productive as a developer. In his opinion giving developers their own office would be the best as it allows them to fully concentrate on the given development tasks. If that is not feasible and you're not working for Joel, then an open room configuration is the next-best compromise. And finally the worst solution: cubicles. Those suckers simply slurp your brain dry…



Well, afterward I headed over to Ari Zilka's talk about Terracotta. He gave an overview/introduction of Terracotta's capabilities. The presentation was quite similar to the talk we had at our monthly AJUG meeting last year but since then Terracotta published a new reference web application (Examinator) that really looks sharp and consist of a very good technology stack besides the fact that it uses Terracotta:
  • Spring MVC
  • Spring Webflow
  • Spring Security
  • JPA (Hibernate)
  • FreeMarker
  • SiteMesh
  • MySQL
One example he gave that stuck with me quite well, was the typical email registration process, when signing up for a new user account. You provide an email address, but before the account can be activated, you need to verify the email address using a verification email. However, using Terracotta, you're able to defer saving the email to the database until verification is complete and thus you can keep "state" information out of the database.

Afterward, I listened to Charlie Hubbard's talk on GridGain. This was an interesting talk in that GridGain is tackling distributed computing from a different angle than Terracotta. You are basically using it to farm out little chunks of data that are then processed by those nodes. It feels very reminiscent to using JMS with Publish/Subscribe with some processing logic bolted on.

After this talk I attended Bill Burke's talk on REST. It is interesting how various frameworks converge to a common point these days - RestEasy looked like Spring MVC 3.0 :-)

The last talk I visited was on Jared's Richardson's talk on 'using agile to optimize' which was a good talk. It reminds me that I still need to read his book Ship It!

At the end of the day we all headed down to the bar and had a few drinks. I met a former colleque of mine and chatted a while with Charlie Hubbard and Lance Gleason. A long good day…

Thursday, March 26, 2009

RIA, Flex and Excitement

I cannot believe that already two weeks passed by since the Atlanta DevNexus conference. Since then I have been quite busy learning Flex. My desire to explore Flex started back when James Ward talked at one of our AJUG meetings several months ago. Unfortunately, beyond some initial explorations, I never found the time to make the next leap forward.

The presentations at the DevNexus conference, though, finally pushed me beyond that initial hump. At the conference I attended the talks for GWT, JavaFX and Flex. Here is what I took away from it:

No doubt, GWT looks great and I think it is in the process of capturing a good share of the pie among Java developers. Since you write the GUI using Java (Compiled into JavaScript), it is a really nice component-based Framework (forget JSF). The ability to unit test your GUI code with just jUnit is cool, too. Something I was not aware of prior to attending DevNexus is the ability to also embed GWT into existing applications (e.g. a DIV on a page). However, at the end of the day you're still creating HTML with its limitations in terms of richness.

In terms of that, JavaFX has potential in my opinion. While it comes with its own scripting language you are still able to use the the full breath of exisitng Java libraries. Unfortunately, JavaFX does not seem to be there, yet. While some of the example application look nice, it still lacks some important pieces, e.g. lots of standard components. At the end of the day, most developers are building business apps and thus need standard components for datagrids, charting etc.

This was also one of the key complaints Yakov Fain (See picture) made at his DevNexus presentation which gave the audience an overview of various RIA technologies. (Another perspective on the JavaFX was posted by Javalobby: Where in the world is JavaFX?)

And therefore, by the end of the conference I was mostly convinced that Adobe Flex is the best technology at the moment for delivering rich internet applications. Don't get me wrong, I still hope that JavaFX can make it and maybe IBM fancies with the idea of becoming a player in that area and provides some more resources once BlueSun is born.

Nevertheless, once the conference was over, I made the decision to take the Flex deep dive. I mostly finished reading Learning Flex 3 and I just started reading Pro Flex on Spring. For both books I am planning on publishing book reviews soon.

As an example I am in the process of creating a simple Flex-based front-end (highly experimental) for jRecruiter my open source project. So far I have setup the Spring BlazeDS 1.0M2 integration and I am pulling back job postings from the server using AMF and showing them in a data-grid component. Furthermore, I added Google Maps to the Flex application which works pretty neat. It gives you the ability to show job postings on a map (and thus helping you estimate possible morning commutes). I hope to have a deployed version available soon. In the meantime, here is an early screen-shot:

Monday, March 16, 2009

DevNexus Audio Files Available Now

Originally we did not plan on recording the sessions during DevNexus 2009, but thanks to the help of Stephen Davis we are able to provide recordings of ten presentations. The quality could be better but I think the presenter is mostly intelligible. The recordings are available here.

Friday, March 13, 2009

DevNexus 2009 Report Part 1

More than half a year of preparation finally culminated in the grande finale from March 10 to 11 at the DevNexus conference. The result was in my opinion a great success. We received many emails from speakers and attendees alike, commenting on the very good quality of the DevNexus conference. This was the biggest event that I helped organizing, yet. I already have a few ideas and areas of improvement for DevNexus 2010. But that is subject of a future blog post…

Overall, I truly enjoyed the speaker line-up. Here are the presentations I attended:

March 10
  1. On the Lam from the Furniture Police by Neil Ford
  2. Terracotta - Real Apps, Real Frameworks, Real Use Cases by Ari Zilka
  3. Introduction to Grid based computing with GridGain by Charlie Hubbard
  4. Scaling RESTful Services with JAX-RS by Bill Burke
  5. Software Teams Tuneup: Using Agile to Optimize by Jared Richardson
  6. Scaling Hibernate: tips, recipes and new perspectives by Emmanuel Bernard
March 11
  1. JavaFX: The Platform for Rich Internet Applications by Doris Chen
  2. Picking the right technology for the Rich Internet Application by Yakov Fain
  3. GWT by Bruce Johnson
  4. Developing Modular Web Applications with Spring 3.0 by Keith Donald
  5. Automatic generation of Flex/Java CRUD applications by Yakov Fain
By the way the slides are available here.

I will try to provide some more details and impressions about the attended talks in the next few days. Stay tuned.