NFJS: Second day

August 8th, 2004 by Hen

The second day began with an attempt to find WaffleHouse (I went to the conference with two professional eaters). We failed and had a Burger King breakfast.

It marvels me how burger joints can not serve burgers before 11 or 12 or whatever. It would seem to be a joke, if it wasn’t true.

Conference wise, the day began for me with Ben Galbraith’s Relax-NG/JDOM talk. I’ve touched on the JARV API with XmlWriter, though only for an XSD (acronym galore…) and had read lots on JDOM over the years but tend to use my own xml parser when hacking for myself (it’s more fun).

Still, Ben’s talk was well prepared and it got me interested in the JARV stuff in XmlWriter again. RelaxNG is a nice tech, and I need to do some work to make XmlWriter work better with it.

Nice bits…. JDOM ships with an XPath parser. Jaxen apparantly. It actually uses a SAX parser from the standard sax/dom stuff.

Something I came across a month ago seemed to fit with this talk for me; a sax+dom parser. Sax to a point, then get a dom snippet: “>saxdomix

I asked Ben why so much energy is spent on parsing XML and so little on outputting XML (XmlWriter and xmlenc seem to be the only focuses here). He mentioned that Stax (capitalization probably wrong), which is a new type of parser called a pull parser, also had an output api that reflected the input.

So something to look at (will list my ‘things to look at’ at the end of this blogging).

This was followed by a talk from Dave Thomas on Mock Objects. Similar to the Reflection talk the day before, I was aware of enough of this content beforehand that it lacked the voyage-of-discovery feeling that NFJS often brings. Major notes I made were that mockobjects.org has a paper called “endo-testing”, java.sql and jms are covered by MockObjects, Groovy is being used to write Unit Tests.

This was a major theme of the conference. Most of the speakers are looking forward to Groovy happening at some point in the future and becoming something we use as a major part of our Java lives.

Next we had an Expert Panel over lunch (transcript to come) and that was followed by Ramnivas Laddad’s double-session talk on AOP and AspectJ.

This was another major part of the conference. Aspects. Everyone seems to be looking to them as the next big thing. The XmlWriter hacking led me to want to sit at a laptop rather than merely listen and so before Ramnivas’ talk I downloaded AspectJ. While he talked I multi-tasked and played with aspects.

It’s very easy to get things working, and you can start doing some pretty fun things. Ramnivas’ talk was very good too. Despite much hyping, it was still a pretty small crowd. I also downloaded JAD and decompiled the compiled-aspected code. Interesting stuff again.

My favourite was how easy it is to do Mixin’s in AspectJ. I’m unsure why people aren’t mentioning this more, there’s probably something important I’m unaware of:

An interface I want to treat as a mixin:

package library;

// oh for mixins

public interface Named {

    public void setName(String s);
    public String getName();
}

A class I want to mix into:

package library;

public class Author implements Named {

    public String toString() { return getName(); }
}

Bit of code to do things with it. Creator is a simple factory class.

package play;

import library.*;
import system.*;

public class Play {

    public static void main(String[] args) {
         Book b = Creator.createBook(”bible”,
          ”various religious sandals”, “1″);
         System.err.println(b.toString());
     }
}

An aspect that mixin’s the desired code:

package playaspect;

import library.Named;

public aspect PlayAspect5 {

     // mixin for Named
     private String Named.name;

     public String Named.getName() {
         return name;
     }

     public void Named.setName(String s) {
         name = s;
     }

}

Doing is a cool way to learn, although it’s probably a bit annoying for the speaker.

All in all, aspects were the highlight of the day for me. Dinner and beer at Outback followed.

Comments are closed.