Archive for June, 2003

PicoContainer “as()”

Monday, June 30th, 2003

Did my first commit on picocontainer on the weekend after lurking for too long — only to find out that Aslak and I had the same idea - there is code in nano to do almost exactly the same thing.

[You can also read the original mail thread]

Say I have an interface:
==

public interface Peelable {
void peel();
}

I want to be able to call peel() on all components in a container
that implement Peelable. Conceptually (at least the way I think about
it), this is like calling peel() on the container itself.
So what if I could dynamically make the container implement any
arbitrary interface:

pico = new MorphingHierarchicalPicoContainer(...);
pico.registerComponent(PeelableComponent.class);
pico.registerComponent(AnotherPeelableComponent.class);
pico.registerComponent(YetAnotherPeelableComponent.class);
pico.start();
//Get a proxy for the container that implements Peelable
Peelable asPeelable = (Peelable) pico.as(Peelable.class);
//Calls peel() on all Peelable components in the container
asPeelable.peel();

This is easy to implement using a dynamic proxy. The proxy just
iterates through the components and calls the interface methods on
each one in turn.
Some of the advantages of this are:
- Totally decoupled lifecycle methods are now possible, because I can
adapt *any* interface, and it is not coupled to Pico at all.
- many competing / complementary lifecycle patterns can be implemented
without comprimising pico’s simplicity
- the interface is decoupled from Pico, interface methods can throw
Exceptions that are domain specific. Again, pico doesn’t need to know.

BankSA sux

Thursday, June 26th, 2003

I have a VISA acount at BankSA (now part of st George). I need to keep it open because I can’t get one in the UK (haven’t been here long enough yet). But there is no way I can pay it off from the UK except sending a bank cheque back to australia — at £10 (about $20) a pop. How’s that for customer service.

Richard II at the Globe

Wednesday, June 25th, 2003

Ben and Karen at the Globe

Sunday we went to the Globe in bankside to see Richard II. We stood of course (there is no better way to see a play here).

Saturday at Greenwich

Wednesday, June 25th, 2003

Greenwich from the hill of the Royal Observatory

On a beautiful Saturday we went to Greenwich, visited the old Naval Hospital (the baroque building with the two towers), Queen Charlotte’s house (the Georgian building in the middle), the Royal Observatory and Greenwich Park. You can tell its a beautiful day because half of London are sitting in Parks with no shirts on. This is not always a good look.

Harry Potter day

Wednesday, June 25th, 2003

Clock of King's Cross station showing half past midnight

This is the clock of King’s Cross station, blurred, showing half past midnight on the 21st June 2003 — the morning that Harry Potter was unleashed. (Actually unleashed should be used of Sirius probably).

Harry Potter day

Wednesday, June 25th, 2003

Clock of King's Cross station showing half past midnight

Ben and I love books. A lot. So when a book steals the limelight from all the movies, TV and other junk around then its worth celebrating. Espescially when its a good book by an already classic author. So at midnight on the 20th we were standing in the queue at King’s Cross station (location of Platform 9 3/4 of course) to pick up my copy. The next day we went to Waterstone’s in Picadilly (which had been ‘magically transformed’ into Harry Potter world) to pick up Ben’s. And the best thing about Harry Potter? Travelling on a bus or the tube at the moment in London you can’t help but notice the surreptitious looks from readers, covert and otherwise (Is he further in than me? / Ah — she’s about to gt to ”’that”’ bit).

Books rule OK!

Monday, June 23rd, 2003

Quoted in the New York Times

“Stephen Riggio, chief executive of Barnes & Noble, the largest bookseller in the country, said the book business had upstaged even Hollywood. The five million copies sold, at retail prices from $17 to $30, surpassed the first weekend’s box office for the latest blockbuster movie, ‘Hulk’, which sold $62.6 million in tickets in its three-day opening weekend.”

I love the fact that books can still enchant like this — although granted this as an extra-ordinary book.

Richard II at the Globe

Monday, June 23rd, 2003

Ben, Karen and I went to the Globe on Sunday to see Richard II, the second play in the ‘Season of Regime Change’. This is an all male production, starring Mark Rylance as Richard.

It is a superb production - Mark Rylance’s Richard is the star turn, but the ensemble has been working together for some time now, and it shows. Even more, the actors are now familiar with the Globe and the audience, and the play with the audience and the physicality of the acting style make any play there a joy.

There was also a moment of surrealism before the start - Karen had texted her brother for a plot synopsis - so we started the play having just read the following: ‘Watch Bolingbroke - he rises up - rip Richard’

Richard is an ineffectual King. We see him at the start of the play at the end of a hunt, joining his court in singing a round over the carcass of a deer. He is not obviously a King, it is not until he speaks that we realise who he is.

His ruling style is much the same, and in this production he spends most of his time being whispered to, as his advisers and flatterers help him vacillate his way to obscurity. Rylance plays him as if he has a very short attention span, and he giggles his way through audiences - always laughing slightly too long at his own jokes.

At one point, York makes a passionate plea for Richard to act justly, and reform his court to get rid of those who flatter rather than advise. The King is meanwhile muttering to one of these advisers, and at the end of a phlegmatic raging speech from York Richard turns to him, flutters his handkerchief and says ‘Why, what’s the matter?’

Richard is eventually replaced as King by Bolingbroke, aka Henry IV, in a remarkably bloodless coup. The scene where Richard hands over his crown is fantastic, full of pathos and bitterness.

Better is to come however, as after the interval Richard, captive in Pomfret castle, muses on his world and his life. It is here that we see the king he might have been - wise, humble, witty. But it is far too late, and ironic that his greatest wit is spent in an empty prison room.

As has become the standard at the Globe, the play ends with a jig - danced by the entire company to the cheers of the audience. As a codicil to the play, there is a perfect moment when Bolingbroke and Richard dance together laughing - a perfect end to a brilliant play.

Static v Non-static loggers

Thursday, June 19th, 2003

One of my co-developers prefers non static loggers over static loggers, ie

private Log log = LogFactory.getLog(getClass());

over

public static Log log = LogFactory.getLog(Foo.class);

beacuse it is easer to copy and paste between classes.

Non-static is bad iin classes that may have many instances of course (because it creates a logger per instance) but often you are using loggers in singletons or few-instance classes and its more convenient to use non-static.

But there’s a nasty gotcha that just got us.

If you serialize a class with a non-static instance, the whole logger (in log4j the whole category) gets serialized with it. This can be really seriously nasty if, for example, youare sending what you expect to be small XML serialized messages across a network, and end up with whole log categories (thousands of extra lines) flying back and forth.

Of course its OK if you make the logger transient, but static is better.

(apologies to Paul)

The Tyburn Tree

Tuesday, June 17th, 2003

memorial at the site of the Tyburn Tree

In the middle of a traffic island near Marble Arch is this marker for the site of the Tyburn Tree. This is where the gallows stood in old london. It is wierd to think that so many people and so much of London’s history has happened on such a non-descript spot