createChat with closure as Listener

hello community

i am using the smack api out uf groovy, but here is my problem.

how to write this bunch of code with a closure as listener?

// Assume we’'ve created an XMPPConnection name “connection”.

ChatManager chatmanager = connection.getChatManager();

Chat newChat = chatmanager.createChat("jsmith@jivesoftware.com", new MessageListener() {

public void processMessage(Chat chat, Message message) {

System.out.println("Received message: " + message);

}

});

i would be thankfull for all hints

greetz digitalkaoz

what does “a closure as Listener” mean?

// the java way

interface Listener{

void use(Object object)

}

aFunction.handle( new Listener(){

public void use(Object object){

object.doSomething()

}

});

//the groovy way

aFunction.handle { object -> object.doSomething()}

and now my question?

how to implement the javacode…

// Assume we’'ve created an XMPPConnection name “connection”.

ChatManager chatmanager = connection.getChatManager();

Chat newChat = chatmanager.createChat("jsmith@jivesoftware.com", new MessageListener() {

public void processMessage(Chat chat, Message message) {

System.out.println("Received message: " + message);

}

});

in grooy style?