Archive for January, 2012

Tracking how my kids’ handwriting changes

Tuesday, January 31st, 2012

A few years ago, I wrote a post about how you can make a font based on a sample of your own handwriting.

I did it to help Grace, at the time aged three, to make a font of her writing as part of a present for Amy.

Graham suggested doing this every year, and as it turns out, that is what I ended up doing.

It’ll be a nice thing to have when she’s older – a record of what her writing used to be like. And it’s fascinating to see how her handwriting develops year-on-year.

120131-grace-comparison

We’ve got a few of them now, so time to share how it looks so far.

(more…)

What has Watson been up to since Jeopardy?

Tuesday, January 24th, 2012

It’s been about a year since the computer system IBM Watson entered a TV quiz show against two of the best people to play the game, and won.

You knew that already, right? If not, skip reading this and go watch some of the footage instead. It’ll be more interesting.

But what has been done with Watson since?

Watson still makes the news even if not as much as during Jeopardy!. And with updates on twitter, facebook and YouTube there’s a lot of info out there about the project.

With all those updates, it’d be useful to bring some of it together into an overview of what sort of work has been taking place in the last year.

(more…)

“FAITH”

Saturday, January 21st, 2012

FAITH

Or, “what happens when we’re in the park with a digital camera and some time to kill”. 🙂

(more…)

Generating a list of REST APIs in JAX-RS

Saturday, January 14th, 2012

Overview

Using Java Reflection to generate a list of REST endpoints defined in JAX-RS code

Background – JAX-RS

I’ve been working on a project that uses JAX-RS – the Java API for RESTful web services. If you don’t know JAX-RS, you write web services in Java using annotations to specify what REST endpoint a Java method implements.

For example, you can use @Path annotations on a class to define the root URI for methods in the class, and then use annotations like @GET, @Produces(MediaType.APPLICATION_JSON) and @Path on the individual class methods to define the endpoints that they implement.

The problem?

Reading from code to the web service is straightforward enough. By which I mean, if I’m looking at a Java method, it’s easy enough to look at it and know what endpoint it is implementing.

Going the other way can be a little trickier.

Once a project gets bigger, you can have REST endpoints spread around a large number of classes. And methods can inherit attributes from other classes than the one they’re in, through annotations like @Parent.

What if I’m using one of the project’s REST APIs, and want to look at the source for the method that’s handling it, whether to extend it or fix a bug? How can I remember which method in which class is responsible for the REST endpoint I’m using?

Using Reflection

Documentation is one way. As I develop the code, maintain a list of the mapping of Java methods to web services endpoints. And keep that up-to-date as I make any changes to the code.

But that’s very manual, and doesn’t seem very smart.

This got me thinking yesterday evening. I’d not used Java Reflection before, but thought it must be possible to work it out from the Java annotations in the same way that my JAX-RS provider must.

So I spent a bit of time trying it out and thought it might be useful to share what I came up with. It’s not terribly elegant or efficient. It’s the result of a few hours tinkering. But it shows the basic idea, and that seems useful enough to warrant sharing.

(more…)