Marek Potociar's Blog

17Nov/118

On JAX-RS 2.0 from Devoxx

Yesterday I gave a talk at Devoxx on what's coming in JAX-RS 2.0 that is planned to go final in the middle of the 2012. On the stage it was hard to see the people because of the spot lights beaming at me, however I could notice that the cinema room for about 450 people was quite full, despite the hard competition from Brian Goetz who was talking about Java SE 8 next door. I did a poll and it turned out that about a third of the people have not worked with JAX-RS before. It was nice to see that JAX-RS is a technology that people care about and that attracts new developers. In fact, today in the morning I ran into a Silicon Valley JUG and GTUG lead in the tram on the way to the conference venue who told me that in his opinion JAX-RS is the technology with perhaps the biggest potential from all current Java EE technologies. Cool,  right? :)

I was little bit nervous with the talk as typically I have at most 15 slides for an hour long talk, but since I wanted to show a lot of code without the danger of spending too much time switching back and forth between slides and IDE, I have put the code into the slides and ended up with a pretty large pile of slides. Also, the night before I took part in an interesting technical discussion that ended up around midnight in a local pub :) . Not sure about the exact correlation ratio, but in the morning I woke up just to realize that I got cold and lost my voice. It got better over the day, but I still could not speak too loud before my talk. Luckily the audio technician was skilled and managed to set up the mic in a way that, although it still did hurt, I could at least speak in a low voice (the only disadvantage was that after the talk two people tweeted that the content was great just the speaker had a sleepy/dry voice). Despite these technical problems I received a very positive feedback overall and I was answering JAX-RS related questions for the next 30 minutes after the talk.

So what did I talk about? See the slides yourself.

Perhaps the most wanted addition to the JAX-RS is the Client API, that would complete the JAX-RS story, that is currently server-side only. In JAX-RS 2.0 we are adding a completely interface-based and fluent client API that blends nicely in with the existing fluent response builder pattern on the server-side. When we started with the client API, the first proposal contained around 30 classes. Thanks to the feedback from our Expert Group we managed to reduce the number of API classes to 14 (2 of them being exceptions)! The resulting is compact while at the same time we still managed to create an API that reflects the method invocation context flow (e.g. once you decide on the target URI and start setting headers on the request, your IDE will not try to offer you a URI setter in the code completion). This is a subtle but very important usability aspect of an API. And if you ever tried to create a (real) fluent API you surely know how hard it is to achieve the result without an explosion of API class/interface numbers. At present the client API is in a draft phase. You can still expect some minor changes in method signatures here and there as we make progress with the underlying API implementation, but the main parts of the client API can be generally considered stable.

The next big feature addition that you can expect from JAX-RS are Filters an Handlers. Filters are essentially reusable providers for Request pre-processing and Response post-processing. The filters are non-wrapping, which means that the filter chain is completely managed by the JAX-RS runtime, including the execution of the filters in the chain. Filters have the way to influence the the chain execution by returning the "next action value", but they do not directly invoke the next filter in the chain (which is where the term non-wrapping comes from). Handlers on the other hand are wrapping (directly invoking the next handler as part of their handle method) interceptors of the message data marshalling and un-marshaling. Whenever a message entity is read or written the request always goes through the handler chain. By default both filters an handlers are applied globally when registered as providers, but JAX-RS 2.0 is going to provide a mechanisms for static as well as dynamic binding of a filter or handler to a particular resource or resource method as well as for specifying a relative order in the filter/handler chain. Dynamic binding is enable via implementing an interface. Static "named" binding is provided via designated named binding annotations.

Since JAX-RS 1.0 came out, many JAX-RS users have requested support for data validation. If you are one of these users, we have a good news for you: JAX-RS 2.0 will provide data validation support by integrating with the standard Bean Validation API. I won't go into too much details here, as the Bean Validation API would itself easily make several blog entries on it's own. The important for us is that by integrating Bean Validation API support into JAX-RS we are providing the JAX-RS users with a very powerful and standard Java API for data validation instead of re-inventing the wheel in JAX-RS spec.

Another notable update in JAX-RS 2.0 is the improved support for working with hyper-links. Current proposal is focused on improved support HTTP link headers. We are extending the existing API as well as making sure the new API additions (client, filters...) are designed with link support in mind. That said, I had two interesting discussions earlier this week with a couple of web client developers who independently pointed out that for them accessing links in HTTP headers is quite difficult and their preferred model is to include all the links in the HTTP entity, typically represented as JSON. I have to admit that we have completely missed this fact in our considerations within JAX-RS EG and this area is something we may still want to look at an revisit the current proposal.

I concluded my talk by a short update on plan to integrate the Java Dependency Injection API (JSR-330) into the JAX-RS. The idea is to slowly move away from the JAX-RS specific @Context injection annotation towards the standard JSR-330 Dependency Injection API. In the first phase we would like to make sure we support @Context and @Inject interchangeably. We would also like to add support for qualified injection (see @Qualifier in DI) as well as think about how to support dependency injection Providers and scopes. The proposal for this area is not finalized yet so I cannot provide more details on the final solution for JAX-RS 2.0 at the moment. We expect to close this task in a month or so.

There are few requested features that are most likely not going to make into JAX-RS 2.0, namely MVC support an high-level client API. In both cases the reasons behind include the lack of consensus in the EG caused primarily by the fact that these areas are still not explored well enough in the proprietary API space to make us feel confident about doing any standardisation work there.

In case you are interested in more details, you can check out the early draft of the specification that was made available for a public review couple of weeks back. You can also check out our JAX-RS Specification Project site on java.net that contains wiki with API proposals as well as (yet to be completed) API javadoc draft. Feel free also to brows through the expert group mailing list archives. Don't forget to subscribe to the users mailing list where all the EG communication is replicated if you want to keep yourself up-to-date with the most recent work in the spec. And most importantly, if you have any feedback, please don't hesitate and send it to the JAX-RS users mailing list.

24Jun/110

Notes from Jazoon 2011

I have just returned from the Jazoon 2011 Conference in Zurich that finished yesterday. Zurich is a beautiful city and I always enjoy my stay there because of it's atmosphere, location and nice people. Everything seems to work well there, including the great system of public transport (how many cities include boats in their public transportation networks?). I only wish they did something about the public smoking which can be particularly annoying under a tram stop shelter on rainy days.

The Jazoon conference was traditionally held in the Arena Filmcity, Zurich's multiplex cinema, with halls featuring 150, 300 and 500 comfortable seats. This year I was presenting a talk about SOAP and REST services looking at the two from a perspective of several typical use case scenarios. The talk was originally submitted a colleague of mine, who could not travel due to a conflict in his schedule, so I can say I got to Jazoon with some portion of luck this year :) You can find the final slides from my presentation here.

Jazoon 2011 Conference

Overall the conference was smaller in attendance and quieter compared previous years. My estimate is around 500 attendees. This was in contrast with the large amount of sessions. Session quality varied both in content and speaker, yet during all three days I was almost always able to choose a good session. From the Java technical sessions, I found particularly interesting the talks on the future of Java by Danny Coward, Using Graddle, Play! web framework, Jazoon Rookie talk on boosting productivity with Hudson/Jenkins, Gerrit and Mylyn as well as the Web security talk by Frank Kim. The Animated Java Concurency presentation by Victor Grazi from Credit Suisse was worth watching too. You can checkout his animation project here.

From the SET track (SET = "Software Engineering Today", whatever that means) I really enjoyed the talk on Self-organizing teams by Joseph Pelrine. Also opening keynote on IaaS and PaaS by David Chapell and closing keynote on JavaSE/EE by Simon Ritter for the Jazoon, Day One were interesting, and - as one would expect - exceptionally well delivered. I was a bit disappointed by the opening keynote for the Jazoon, Day Two delivered by Linda Rising. Linda is a great speaker but I found her talk somewhat shallow in content this time, maybe I just had my expectations set too high. Also, I may be nitpicking here, but if a keynote speaker does not bother using the official conference presentation template, who should?

The closing keynote for the whole conference by Pouline Middleton was, despite somewhat prosy title, surprisingly refreshing. If you don't know Pouline and never heard of her fiction diary One Woman Three Men, which - interestingly - is based on her own personal life experience, you should check it out.

Jazoon.next

As I said earlier, the Jazoon conference was despite the large number of talks and a new track focused on Microsoft technology smaller in attendance compared to previous years. I can only speculate about the reasons, but hey, this is my blog, so here are my thoughts:

Jazoon organisers need to decide who is their target audience. Zurich is an expensive location and the conference fee is not particularly low either. With that, the conference should IMO retain a narrow focus to be able to provide quality that would justify the premium price. Broadening the scope may not be the best strategy for such conference. I am not sure that adding Microsoft track to a conference with a name suggesting a Java related content was necessarily a good decision. (And I say that despite the fact that I won a really cool mouse and an XBox game in the Kinect-powered virtual Wheel of Fortune at Microsoft booth.) For one reason or another, the sessions on the Microsoft track were poorly attended. Obviously this track did not attract many new attendees to Jazoon.

The amount of sessions this year was astonishing. If my calculations are correct, there were 112 (!) sessions delivered at Jazoon this year. That's a huge number compared to the number of attendees. The problem with the number is that the high number seemed to be achieved at the expense of the quality of the talks and/or speakers. In future, the Jazoon organisers should do better job in reviewing quality of the submitted talks AND the quality of speakers. The way I see it, much smaller amount of high(er)-quality speakers and sessions could attract many more people. Sometimes simply less is more.

On a similar note, I was surprised that organisers still did not implement any means for collecting an immediate feedback from attendees on the quality of the sessions and speakers. Such data would help them in their submission reviews in the coming years. Also, using just a single twitter aggregation page as the only dynamic content element is just not enough for a technical conference these days anymore.

At last, I find it somewhat unreasonable to host a conference for 500 people in a venue with capacity to host simultaneously 10 sessions for more than 2000 attendees in total. It seems to me that smaller venue could help to reduce the costs of the conference and as such make the fees more affordable.

All right, enough ranting. I would like to state that despite all of the above I had a good time and I found the conference refreshing and inspiring. I hope the conference organisers will be successful in helping Jazoon to regain its former momentum, so that it remains a relevant international Java conference for the years to come. Good luck, Jazoon!

27May/111

Oracle Java Developer Conference 2011 in Brno, Czech Republic

Yesterday I took part at local Oracle Java Developer Conference 2011 in Brno, Czech Republic. The conference was a great success and the attendance highly surpassed our expectations, most of the attendees being professional developers. The agenda was impressive, focused on latest development in Java SE, EE and tools.

Together with my colleague Jakub Podlesak, we had a talk on REST and JAX-RS API. This was actually my first ever talk on REST and JAX-RS since I took over leading the JAX-RS 2.0 specification project (officially filed in JCP as JSR-339). At the beginning of the presentation I did a short introduction into REST and JAX-RS and then Jakub did a few practical demonstrations showing how things work in practice. In the end I gave a short overview on what are the future plans in JAX-RS. The audience was great and very interested in the topic. With Jakub we stayed for another 40 minutes to answer the constant stream of questions. I have to say that seeing such interest in our work is both refreshing and encouraging. I would like to thank everyone who attended the conference and our session for creating such a wonderful atmosphere. If you are interested, Jakub has published the slides as well as demos from our presentation.

See you next year!