November 3rd, 2011

by Ivan St. Ivanov

Hello Java2Days 2011! The conference season finally started for me! This is my third Java2Days conference and I can admit that I could hardly wait for it to start. The timing this year was perfect – a month after JavaOne and ten days before Devoxx. The speakers’ lineup was also pretty impressive. Besides the guys that we already knew from previous editions of the conference (Vasil Dichev, Oleg Zhurakousky, Josh Long, Andrew Lombardi, Nikolche Mihaylovski to name a few) we had some new rock stars as Spring’s Juergen Hoeller and JBoss’s Andrew Lee Rubinger and Lincoln Baxter III. I expected to see Alexis Moussine and Reza Rahman, but they didn’t come this year. Another big absence is that of SAP. After having 15 speakers last year they decided not to present anything on this occasion. But anyway, let’s go straight to the


… or at least I expected to see something like a keynote. Our organizers did it in the JavaOne way – they reserved the first half an hour for their sponsors. We had a guy from Vivacom who talked about a contest they organized. Then on the stage came my former colleague Peter Minev, who is now manager in VMWare. He talked too about a contest his company is organizing, but before that gave us a brief overview of what his co-workers are going to talk about during the two conference days.
The difference with the JavaOne keynotes was that we did not have the “big news” section after the partners part. So we were directly invited to the first presentation – something about Oracle and the cloud. As I am very suspicious towards Oracle speakers who are not former Sun employees, my choice for the first time slot was a no brainer. I headed towards the

Scala for Java developers talk

I knew the speaker – Vasil Dichev. We worked together 10 years ago. I knew about his passion for the Scala programming language. I must confess that I went to his talk being afraid that he’s going to give us the same presentation as last year. Well, I was wrong.
We had our first NoSpaceInTheRoomException. The hall was too small for everybody who wanted to see this talk and I was sorry that Remember the milk (the company for which Vasil is working) was not a sponsor of the conference ;-). I was also afraid that we may lose a lot of time to look at the various features which bring the notion that Scala is hard and purely academic language. Hopefully the speaker chose another approach – as the room was full mainly of Java developers, Vasil compared the Java language features introduced in Java 5 and Java 7 with their Scala counterparts.
We saw about Scala that:
  • It doesn’t have primitive types. However it is not a problem in the runtime as the compiler is smart enough to create very optimized byte code
  • It has sealed traits instead of enumerated types. The big idea here is that if you are doing a switch/case in these sealed traits (in Scala this is actually done via pattern matching), the compiler will warn you if you miss to handle some of them. So this makes Scala’s “enums” even safer than Java’s
  • You can have not only static imports, but you can also import instance methods. More over you can create an alias for an imported type and use that in the scope of the current class (think how useful it is if you need to import in one class java.util.Date and java.sql.Date)
  • There is no break and continue statements in Scala
  • The type inference is well beyond Java 7’s diamond operator
Of course Vasil didn’t forget to touch another hot topic, which was postponed to Java 8 – the lambda expressions. Besides giving an example of the proposed syntax in Java and the one in Scala, he briefly explained the difference between lambda expression and closure. The conclusion was that Java will have only lambdas, while Scala has full blown closures (code blocks can change their enclosing state).
The whole presentation was concentrated around several well known facts about Scala: it is concise, statically typed and every single language feature is used universally throughout the whole language (you can do 1 + 1 because 1 is of type Number, it has a method called + and you can omit the dot and the parenthesis).
The final conclusion of the talk was that Scala is not the next Java. Vasko was afraid to state that, because they said the same thing about JavaScript and C++ and these are amongst the most hated languages these days. And he doesn’t want the same fate for Scala.
My impression was that the communication between the speaker and the audience was great. One of the reasons is the fact that Vasil was very well prepared. But I can also say that the small room accommodated it as well. I will definitely go to tomorrow’s talk on actors, no matter that I already watched something similar and even though it clashes with the session on Spring Roo.

Spring’s perspective on Enterprise Java

The next talk was by Juergen Hoeller from SpringSource and I must say that his participation at this year’s Java2Days is great honor and pleasure for the whole Bulgarian Java community. I think that most of the people were on the same wave as the big conference hall was full. I must confess that I was afraid that he was going to give us yet another “What’s new in Spring 3.0 session”, but I was not right (again). His talk circulated mostly around a very old idea of SpringSource’s CEO Rod Johnson (at least I heard it from him for the first time) – the whole standardization process around Java EE stops innovation inside companies who want to stay compliant.
But first things first. Juergen expressed his view on what is cool at the moment:
  • Alternative data stores (he avoided the term NoSQL)
  • Various client side technologies
  • Concurrency (fork join framework)
  • Alternative languages on the JVM
If you want to use one of these into your [cloud] application you don’t have to wait for them to enter the Java EE specification. Its current version (Java EE 6) represents the state of the art from 2007-2009. The most important thing here is that you have to act now and come with the right solution at the right time even if someone can call this solution proprietary. This is what Spring framework is trying to do: integrate as many “proprietary” enterprise solutions as possible so that it can achieve its own way of standardizing them and making developer’s life easier. I thought that this would cause the next religious wars with the Java EE guys, but looking at Andrew Rubinger’s tweets from this morning I got that Spring and Java EE are not orthogonal any more.
In the second half of his talk, Juergen showed what’s new in Spring 3.1, which is just around the corner (globally available at the end of the month):
  • Specify different configurations for different deployment environments. You can configure different data sources or caching implementations for the different environments where your application is running – dev, staging, production. It can be done both in Java code and in XML
  • Support for caching frameworks different than EhCache
  • No more web.xml and persistence.xml in the web applications – you can declare servlet listeners and filters and entity manager settings in Java code
  • Injection of ForkJoinPool as if it were normal Spring bean
Spring is ready for Java 8 – most of its interfaces follow the single abstract method pattern. So what is now implemented with [anonymous] inner classes, can be replaced with lambdas without any effort.
These and some more cool new feature may be found in this brief InfoQ review.
Juergen’s conclusion was that specifications are important for a lot of things, but not for everything.

Hello JavaFX!

When going to the JavaFX session (actually I just moved a couple of rows forward – it was in the same hall), I had two concerns. I was afraid that it would be an advanced talk (I am less than newbie in the topic). The other thing was that the speaker was from Oracle and I didn’t want to see yet another corporate talk on the variety of products they offer. However, the agenda was promising – it looked as swift introduction into the technology. And the presenter was a former Sun employee and current technical lead, which ensured that this would be a real no-soft-skills talk.
Michael (this is the speaker’s name) began with a short introduction of JavaFX and continued with the reasons why JavaFX script was abandoned:
  • The technology should be easier to use by Java developers without pushing them to learn yet another language just for structuring the UI
  • JavaFX applications should be easier to use by other languages on the JVM
One of the coolest things in the talk was that the presentation itself was written in JavaFX and not in one of the conventional tools for that (MS Office, Open Office,…).
Michael went on to explain the different aspects of the technology:
  • The scenegraph together with the different types of nodes (shapes, images, text, UI controls, media, etc.) and the different kinds of positioning and grouping
  • The animation API with the transitions, timelines and tangent interpolations to create much better and realistic animations
  • The media API with the predefined controls for playing and manipulating music and video
  • The different kinds of UI controls. These are the first part of JavaFX that is going to be open sourced
  • Finally the most interesting part – properties and binding APIs. I must say that in the world of properties languages like Groovy or Scala (and even JavaFX script) shine. The JavaBeans style (though a little bit simplified now) for defining them is so verbose!
The motto of the talk was that JavaFX brings simplicity and at the same time power to Java developer’s toolbox.

Idle times

I think that I didn’t plan well for the first three slots in the afternoon. First I missed Nikolche’s talk on annotation based code generation. Then I went to the HTML 5 talk by Andrew Lombardi only to find out that it is the same as the one from the last year. So I went upstairs to catch the remainder of Oleg Zhurakousky’s session on Enterprise Integration Patterns (the title sounded a little bit different though).
I had some basic idea about this after I read Apache Camel’s cheat sheet. I got that my “favorite” Map-Reduce algorithm is actually called Splitter-Aggregation in the enterprise integration vocabulary. Again very positive communication between the speaker and the audience!
Next I planned to stay for Josh Long’s talk on “Taking your application to the cloud”, but the room remained as full as during Oleg’s presentation, so I went back downstairs. In the big hall a guy from Playtech (Armin Gal) had just started talking about using Hazelcast for building distributed real time applications. Was it because I was tired, or maybe because I am not so interested in this topic, but I went outside to take some fresh air and caffeine and prepare for the…

JBoss time, baby!

The last two sessions of the day in the big hall were by the JBoss guys.
First Andrew Lee Rubinger talked about integration testing Java EE application. I was particularly interested in this topic because I recently came up with an idea to apply the ShrinkWrap API principles when testing the monster [non-Java EE] tool that we are developing at work. I already watched something very similar on Vimeo, presented by Andrew together with the Arquillian guy – Aslak Knutsen.
The greatest value of the already mentioned ShrinkWrap is to bridge the gap between the IDE where you write your productive code and tests on the one side and the container (or more generally the environment) where they are executed on the other. With the general approach you have to run your build (and wait for it to finish) just to bring some bytes into an archive, which then archive is then decomposed to these same bytes while being deployed in the container. So ShrinkWrap saves us from the need [and time] to create an archive (aka the man in the middle).
The second half of the integration testing process is writing the mere tests. For that the Arquillian library is used. To put it simply it represents a JUnit test runner (TestNG is also supported though), which lets you declare what you want in your “archive”, what you need from your container (in terms of EJBs or other CDI beans/resources) and eventually lets you write the real tests. I will not go into further details here as one of the last postings that I wrote (it was nearly a year ago, see how lazy I am!) explains Arquillian in greater details.
After that Lincoln Baxter III came on the stage to present us something that most of the web developers underestimate – URL rewriting. It lets you do a lot of things:
  • Have prettier and friendlier URLs in your application that are understandable by humans and not only by the computer
  • Hide some implementation details about the technology that you are using and the topology of your application
  • Avoid nasty 404 return codes when someone hits an invalid URL (well, some of the 404 pages that he showed were just the opposite to nasty – very funny)
  • Hide request parameters using a hash
Lincoln and his company (OCPSoft) appear to be the authors of two of the three URL rewriting libraries in the Java world. His first one (PrettyFaces) supports just JSF pages, while the next one (URLRewrite) has various other features:
  • Support for other technologies like Struts for example
  • Validation, parameterization and transformation of URLs
  • Both inbound and outbound URL rewriting
  • Redirecting to different pages based on various conditions
The rules for the URL rewriting are defined in Java code with nice fluent interfaces.
I’m looking forward to tomorrow’s presentation by Lincoln on Seam Forge. Until then have some sleep and prepare for another busy day in the third Java2Days conference!