Tuesday, October 13, 2009

Hit the road Jack

Now that I am done with my what took a lot of my time recently, I will be on the road for pretty much the whole month of november all over Europe to spread the word.

First and foremost, I will inaugurate the new MarsJUG (in Marseille) on October 15th. I will be talking about Hibernate Search and how to implement clever full-text search engines using approximations (phonetic approximation etc).

I will also be speaking in Munich at the W-JAX conference on November 10th and 11th. This time I will cover:

  • Bean Validation (JSR-303) and Hibernate Validator 4 (just released)
  • What's new in Java Persistence 2.0. I will spend a good chunk of it to explain the new type-safe Criteria API
  • Hibernate Search and how to do full-text searches with Hibernate-based applications

Next in line is Devoxx where I will give a university talk on Hibernate Search. If you want to know everything about Hibernate Search, this is the time! This is November 17th in the afternoon. This is an interesting format (3 hours), where i will cover a bunch of what is in my book Hibernate Search in Action and do a handful of demonstrations.

Last but not least, I will be speaking at JavaEdge '09 on November 16th in Israel. This time about Bean Validation and Hibernate 4.

If you come by these cities at the right time, come and join me! Between one of these conferences is my birthday :o)

Edit: I forgot that I will be speaking at the ParisJUG on December 8th about Bean Validation. Right after a healthy debate on Spring vs EE 6 (I heard that extra medics and blood supply have been planned)

Thursday, September 24, 2009

JBoss Community Asylum - a new podcast with bits of me in it

Remember my French podcast Les Cast Codeurs? (Doing well, thank you for asking) Well apparently, I did not have enough and started a new one. In English this time.

JBoss Community Asylum. A podcast on, by and about the JBoss Community and its gazilllllllion projects and ideas. It's available here and the iTunes link is here. Basically, instead of blaming people about the lack of podcasts on the great tech at jboss.org, Max R. Andersen (JBoss Tools), Michael Neale (Drools + cloud thingies) and me have decided to give it a shot. You will get the latest news on from the JBoss sphere and we will likely interview folks about their projects.

Let us know what you think and how you would like it to evolve. It's a low-key bottom-up approach so anything's possible.

PS: I made progress, I am not the sound engineer this time, yeah!

Monday, August 10, 2009

Book review: Dependency Injection by Dhanji Prasanna

Over the last few days, I have been reading Dependency Injection by Dhanji Prasanna published by Manning. I must admit, this is a much easier task than writing Hibernate Search in Action ;)

Summary first: very easy to read, a gold mine of knowledge and tips on a subject that is essential to the life of today's Java developers. Go buy it and keep it around your desk.

Let's quickly talk about the book structure. The book walks you gently through the DI (Dependency Injection) subject:

  • why do you need DI, what does it solves concretely in application developments
  • what is injection, what are the main concepts
  • using DI to improve application modularity
  • object scoping and how to approach that with DI solutions
  • best practices learnt with tears and blood
  • and a small concrete application showing how to use Guice as your DI container

If you are a beginner, this book will explain to you how and why using DI. If you are an expert and use DI on a daily basis, this book will help you rethink what you have taken for granted in DI-land and learn a handful of new tricks and design patterns.

I consider DI and the notion of scope (aka context) to be an essential knowledge to any Java developers. This will become even more pressing with the soon arrival of JSR-330 (Dependency Injection for Java) and JSR-299 (Context and Dependency Injection for the EE platform aka Web Beans) and their inclusion in Java EE 6.

Just like you had to learn polymorphism, you need to learn DI and context management as this is an essential tool for proper component design and application modularization.

The only gotcha is that this book comes right before the finalization of the two JSRs and hence does not cover them. Don't be too afraid though, all the core concepts covered by these specifications are thoroughly explained in this book. The problem / solution approach used by Dhanji will perfectly complement your knowledge of the DI JSRs.

My advice is to keep this book on your desk when you develop (next to Hibernate Search in Action mine of course ;) ), you will save yourself the burden of learning the best design approaches the hard way.

Tuesday, July 7, 2009

Lies, damned lies, and statistics: EE edition

I came across some figures regarding downloads of Glassfish and JBoss AS that really puzzled me. Basically Glassfish was downloaded 700.000 times a month (end of '08) while JBoss AS was only downloaded around 115.000 times a month at the same. My first reaction was "Well done to you, Sun!" and then I realized that the gap was too good to be true. Let's have a look at these numbers.

For JBoss AS, the Sun team has only counted the direct number of downloads out of SourceForge. That's public knowledge by the way, go there for the JBoss stats.

For Glassfish (according to this), downloads numbers (not public BTW) come from:

Surprisingly, no stats on the direct number of downloads from the Glassfish project page. Let's analyze that a bit.

JDK bundles is the thing downloaded even by my grand'ma by accident. I can tell you right there, she has never ever used Glassfish ( nor JBoss ;) ). How many times, did I download the whole enchilada while I just wanted the plain old JDK!

Java EE SDK. This one is hard. Of course, people interested in EE will go download this package. Are they interested in GF? Hard to say. On the other hand providing a SDK without runtime will do no good.

NetBeans. I'm surprised at the popularity of NB, but there it is. Are all NB users actually GF users? BTW NB also comes with a JDK bundle but I don't know if this bundle also bundle GF :)

Let's call this strategy the Russian doll statistic generation strategy. Frankly, that's not very honest for your users and customers to use this strategy and then compare apple to oranges with your competition. When someone downloads JBoss AS, for sure he did not do it by accident (thanks to SourceForce's sense of UI :) )

So we have two strategies here, JBoss could start playing the Russian doll statistics generation strategy and we can be pretty good at it:

  • include JBoss AS in Fedora and count it
  • include JBoss AS in RHEL and count it (Dell, IBM and the like are pretty good at delivering RHEL on their hardware)
  • include JBoss AS in IcedTea and count it
  • include JBoss AS in JBoss Tools and count it
  • include JBoss AS Core in JBoss ESB, Portal etc etc and count it
  • include the number of downloads from our maven repository (with the number of times you have to nuke your local repo that will be a big hit :) )
  • I've only added a few ideas but for sure our marketing guys can be more productive

Of course we won't do that. An alternative strategy would be for the Glassfish team to only display their direct download numbers (the one they fail to display) and stop using bogus charts in their public and private slides.

On a side note, I find it disappointing that open source projects don't keep their stats open and preferably via a third party provider like SourceForge. Granted the SF stats are somewhat flaky but it keeps everyone honest with their own (lack of) success.

Disclaimer: I am not saying Glassfish is not a success, I am quite happy to have them as coopetitors on the server market in general and Java EE in particular.

Monday, June 22, 2009

Having problems with Adium and Yahoo IM?

Yahoo has changed its login protocol, breaking a number of third party IM clients including Adium.

The Adium team has released 1.3.5.rc1 which solves the issue. Check it out. If you use Adium 1.4 beta, upgrade to beta7.

Hope this will save you some time.

Thursday, April 30, 2009

Java generics end of mystery

Remember my puzzlement in front of http://blog.emmanuelbernard.com/2009/04/java-generics-mystery.html?

I usually try to make sense of the unknown type by looking at what should be allowed when two incompatible types are used as the unknown type, and then using the generic type using the unknown type as a reference to a known type to see what incorrect things can be done through the reference. If the assignment your questioning was allowed, you would be able to add two incompatible ConstraintValidators to the validatedAddresses as in:

class Address {}
class Person {}

// A set of ConstraintValidator for Address
Set<ConstraintValidator<Address>> validatedAddresses =
    new HashSet<ConstraintValidator<Address>>();

// A set of ConstraintValidator of a single unknown type (*)
Set<ConstraintValidator<?>> validatedThings = validatedAddresses;

ConstraintValidator<Address> a;
ConstraintValidator<Person> p;

// A ConstraintValidator of unknown type, ? = Address
ConstraintValidator<?> thingA = a;

// A ConstraintValidator of unknown type, ? = Person
ConstraintValidator<?> thingP = p;

// This would be allowed if (*) was a valid assignment, which puts a ConstraintValidator<Person> in a set of ConstraintValidator<Address>

validatedThings.add(thingP);


What I missed initially is that I cannot add new (and potentially heterogeneous) elements in Set<?> or Set<? extends X>, but I am free to add elements in Set<X<?>>:


Set<A<?>> c1 = new HashSet<A<?>>();
c1.add( new A<B>() );
c1.add( new A<C>() );

Set<? extends A<?>> c1 = new HashSet<A<?>>();
c1.add( new A<B>() ); <-- compilation error
c1.add( new A<C>() ); <-- compilation error

While the first example compiles, the second does not.

So to answer my initial mystery, I need to use the <? extends X<?>> approach (thanks Vivien for pointing that out).

Set<? extends ConstraintValidator<?>> valiatedThings = ...;

Wednesday, April 29, 2009

Java generics mystery

Here is a puzzle for Generics gurus.

Can somebody explain why

Set<Address> addresses = new HashSet<Address>();
Set<?> things = addresses;

compiles but

Set<ConstraintValidator<Address>> validatedAddresses = 
    new HashSet<ConstraintValidator<Address>>();
Set<ConstraintValidator<?>> validatedThings =
    validatedAddresses;

does not compile?

More specifically, the assignment on the second line breaks.