Archive for the ‘Java’ Category

Inauguration du Mars JUG

Wednesday, October 7th, 2009

Le Mars JUG fera son inauguration le jeudi 15 octobre 2009 lors de l’Agile Tour.

Emmanuel Bernard a accepté d’être le parrain du JUG et cela nous fait très plaisir, il sera aussi le premier conférencier du JUG et nous parlera d’Hibernate Search, un projet qui permet de faire des requetes full-texte tout en utilisant Hibernate. Il explorera entre autre comment les recherches approximatives telles que la recherche phonetique sont implementées.

Les passionnés d’Agilité et de Java seront comblés car le JUG s’est associé à l’Agile Tour (participation gratuite, inscription ici) pour l’inauguration. Le but est de créer une synergie entre les deux évènements qui sont en général assez rare dans la région PACA. Je tiens à remercier Viaxoft et plus particulièrement Karine pour cette collaboration.

Dimitri Rodolphe Baeli un collègue d’eXo Platform sera lui présent mais durant l’Agile Tour pour faire un tour des pratiques TDD en entreprise.

Le but du Mars JUG est de fédérer autour de Java et de créer une communauté dans notre région, j’espère que vous répondrez présent à l’appel le 15 octobre.

Advanced Java reflection framework needs a (good enough) name

Friday, July 17th, 2009

I have been working during the past few days on a reflection framework for Java. Beside the complexity of the actual reflection layer, the developer is pretty much left to himself to perform advanced operations such as type variable resolution or annotation discovery based on the type inheritance hierarchy.

Furthermore this reflection framework is implemented with the runtime java reflection API (java.lang.reflect.Type and its implementations) and the compile time java reflection API (javax.lang.model.type.*). It means you can perform compile time reflection or runtime reflection with the same code. I forgot to mention that the java compile time API is awful.

The first reason I wrote this framework was to perform type variable resolution based on a specific class. I needed to perform such operations for a new project (that I will announce soon, stay tuned).

Let me give you an example:

public class A<V> {

  private final V value;

  public A(V value) {
    this.value = value;
  }

  public V getValue() {
    return value;
  }

public class B extends A<String> {
  public B(String value) {
    super(value);
  }
}

Now if we want to know what is the value of the type variable V at runtime for the class B, the code to perform the resolution is pretty tricky to write and requires a fairly good knowledge of the java type system, although it’s a very intuitive operation to do. Let me give you another example:

public class Event<S> {

  private S source;

  public Event(S source) {
    this.source = source;
  }

  public S getSource() {
    return source;
  }

}
public interface Listener<S> {

  void onEvent(Event<S> event);
}

public class FooListener implements Listener<String> {
  void onEvent(Event<String> event);
}

Although we all know that Java type erasure will not give us the type of S at runtime from instances of the Event class, any implementation of the Listener interface will carry the information about the type variable. Note that it may not be possible to resolve it if the subclass does not bind the variable to a type. It is therefore possible for the framework broadcasting events to know if a listener is able to receive events from a particular source.

Since Java 6 it becomes very easy to process source code at compile time (as exhibited by Gavin King during his researches about the type safe criteria API for JPA). For instance it would be possible to replace the need for CGLib at runtime by a library that would perform a similar work at compile time (actually I wrote pretty much that in the forthcoming project). The advanced Java reflection framework helps to hide the java compile time reflection API. The compile time API is source code oriented but does expose the same semantics as the runtime API.

Another neat feature is the resolution of annotations along a type hierarchy which is very useful if you want to determine the annotation of a type or a method taking in account the type hierarchy. Very useful in the following situation

@Foo
public interface A {
  @Bar void m();
}

public class B implements A {
  public void m() {
  }
}

Finally the framework has some nice stuff coming in, such as the inclusion of the visitor pattern that allows you to perform an operation along the hierarchy of a type, the obtention of the raw class type of any type which attempts to unify the raw type of a parameterized type and the elimination of the synthetic methods due to the return type covariance.

I plan to host that reflection framework project soon somewhere (under LGPL) because I think it will be useful to anyone performing advanced operations with the Java reflection. What is missing for now is a decent name for the project since I haven’t been able to come up with something nice. If you have a good suggestion, don’t hesitate to send me an email (go on www.julienviet.com for the @).

Marseille JUG au BarCamp Marseille 2!

Sunday, April 19th, 2009

Vendredi 7 avril j’ai participé au BarCamp Marseille 2 pour promouvoir la création du Marseille JUG.

Les évènements orientés nouvelles technologies sont plutot rares sur Marseille et c’est ma première participation à un BarCamp. A vrai dire je ne connaissais pas ce concept avant cette occasion dont j’ai connu l’existence via le Twit de Charles, rencontré de visu justement durant l’occasion.

L’école d’ingénieur Supinfo Marseille hébergeait le BarCamp pour l’occasion ce qui m’a donné l’occasion de visiter les docks qui ont été rénovés il y a quelques années. J’avais déjà visité un peu les docks et j’ai constaté que l’intérieur des batiments est aussi beau que l’aspect extérieur le laisse penser.

A présent, venons en aux faits! furent présents lors de la réunion:

  • Alain Defrance formateur Java à Supinfo
  • Yann Vigara revenu de Paris il y a quelques mois et qui démarre une activité d’hébergeur Java
  • Alexandre Terasson et Florien Berton élèves à Supinfo
  • Cyril Bourgès étudiant en master SIS de Luminy
  • Moi même

La réunion a d’abord commencé par les cordialités d’usage à savoir la présentation de chacun des participants.

Il faut savoir que notre aventure du Marseille JUG a débuté il y a quelques semaines.  Khaled, Colin, Alain et moi même nous sommes déjà rencontré plusieurs fois avant le BarCamp (malheureusement Khaled et Colin n’ont pas pu participer au meeting BarCamp). Nous avions donc déjà donné une direction au JUG et cela a été l’occasion d’exposer nos décisions. Je rassure tout de même, celles ci sont assez standard et nous n’auront pas une gouvernance basée sur le totalitarisme, en fait la plupart d’entre elles émargent de la lecture de la mailing list des JUG leaders français. Voici donc les points que nous avons discutés:

  • Direction collégiale avec des status basés sur la notion de co présidents. Cela nous est apparu comme le mode idéal et a suggéré par un JUG ayant ce mode de gouvernance
  • Volonté de faire une réunion unique avant fin juin 2009 et mise en place d’un calendrier de réunions pour la saison 2009/2010
  • Recherche de partenaires et de sponsors financiers pour aider le JUG

Il apparaît que Supinfo fournira un partenariat afin que le JUG puisse profiter des locaux de l’école. Ceux ci semblent idéaux car modernes et avec une position géographique très avantageante. Nous souhaiterions effectuer une réunion mensuelle du JUG, vraisemblablement le mercredi qui est un jour où nous pourrions utiliser la salle aussi bien l’après midi que le soir (probablement 18h).

Finalement nous avons conclu qu’à présent la prochaine action à effectuer est de s’occuper de tout le travail administratif qui fondera le JUG en tant qu’assocation 1901. Ceci est un mal plus que nécéssaire pour la création du JUG.

Longue vie au Marseille JUG!

Soirée SOA au Riviera JUG le vendredi 10 avril 2009

Friday, April 3rd, 2009

Le Riviera JUG organise sa deuxième rencontre le 10 avril sur le theme SOA, si vous êtes intéressé vous trouverez plus d’information sur cette page.

Marseille JUG

Thursday, April 2nd, 2009

Depuis quelques mois une folie créatrice de groupes d’utilisateurs Java (JUG) envahit la France et un JUG se monte naturellement dans la région de Marseille. Si vous êtes intéressé de quelque manière que ce soit, vous pouvez prendre contact avec l’équipe du JUG.

What’s new and cool in Portlet 2.0

Thursday, September 18th, 2008

I just made my presentation available on SlideShare!

Portlet 2.0 @ JavaZone 2008 18th of September

Monday, September 8th, 2008

I will be speaking next week at JavaZone 2008 about Portlet 2.0 aka JSR 286. The talk title is “What’s new and cool in Portlet 2.0″ and it’s about the new features in the JSR 286 specification. I’ll introduce the new key features of the spec with demonstrations.

My session is on Thursday 18th of September 2008 at 3:45 pm. You can find more information on that page. I’ll be there during the full event so if you want to meet and have a drink, it will be with great pleasure.

Massive mail import in GMail

Monday, August 25th, 2008

Recently I had to archive a consequent number of mails into GMail. I don’t want to keep those mails in my Mail User Agent (Mail.app), yet I want to be able to search and retrieve any single mail. Of course I’m keeping an mbox version of those mails but once it’s in an mbox, it’s kind of dead because you cannot easily read one mail or search the mbox.

I considered several solutions and the simplest I could find is to dedicate one GMail account for that purpose. The only drawback is to have internet access but I’m fine with that. In addition the IMAP support provided by GMail allows to do that without any hacks.

Once my special GMail account was created, I started to use my mail client to copy the messages in dedicated folders in the archive account. It was working fine for a small number of messages like 5000. Some of my mailboxes have way more messages, like 60,000. Above 5000 messsages, it becomes a nightmare for two reasons:

  • The mail client synchronizes with the archive account which slows down the whole process.
  • Network failures are more likely to happen and make the whole process very fragile. When you have a network failure you don’t know how your mail client will hold the resume.
I started to look around for solutions but I did not find something that would work out well for me. So I started to create my own solution, that would just do the job. Obviously I used Java as it offers all the low level API and frameworks to build the solution:
Then I wrote a few classes using the above frameworks to perform the massive import. It turns out to work very well and deals with network failures when it happens. I won’t make an open source project because I don’t have extra time to invest in that, however if someone is interested in getting the source code, I would give it as it is.