I miss my monkeypatch.

I miss my monkeypatch.

If you have done a decent amount of python code, you’ve probably run into monkey patching – if you haven’t, you’re missing out. But in java, where I use an ever increasing number of open source libraries, I missed this lovely feature I was able to use to good effect in Plone. But no more, now there is AspectJ to the rescue.

First off, the problem I had was to extend the code generation capabilities in Axis 1.3 to generate java code from a WSDL (which is better than the other way around). But WSDL2Java extension is limited, and I don’t feel like downloading all the Axis source and changing it and recompiling it myself. All I wanted to do was to make the java code that was created include a unique ID to make the objects easier to persist in hibernate (and just to be a show-off, yes I am using Spring too, but not for code generation – it’s not good for everything :).

So how to do it? Easy enough, use the cuckoo’s egg design pattern to replace Axis’s current java class generator with an instance of my own when the constructor is called:

import java.util.Vector;
import org.apache.axis.wsdl.symbolTable.TypeEntry;
import org.apache.axis.wsdl.toJava.Emitter;
import org.apache.axis.wsdl.toJava.JavaBeanWriter;
import org.apache.axis.wsdl.toJava.JavaWriter;
import org.kookster.PersistentJavaBeanWriter;

/**
* Use this to change the behaviour of the WSDL2Java axis code gen
*
* @author kookster
*/
public aspect ReplaceJavaBeanWriterAspect {

//here's a pointcut to get the public constructor of Axis JavaBeanWriter
public pointcut javaBeanWriterConstructor( Emitter emitter,
                                         TypeEntry type,
                                         Vector elements,
                                         TypeEntry extendType,
                                         Vector attributes,
                                         JavaWriter helper ):
  call( JavaBeanWriter.new( Emitter,TypeEntry,Vector,TypeEntry,Vector,JavaWriter )) &&
  args( emitter,type,elements,extendType,attributes,helper );

//here is the advice which calls the constructor for my object instead
JavaBeanWriter around( Emitter emitter,
                      TypeEntry type,
                      Vector elements,
                      TypeEntry extendType,
                      Vector attributes,
                      JavaWriter helper) :
javaBeanWriterConstructor( emitter,type,elements,extendType,attributes,helper )
{
  return new PersistentJavaBeanWriter(emitter,type,elements,extendType,attributes,helper);
}

}

well, finally.

well, finally.

I spent the last few days trying to revive an old pII/350mhz PC.
Having exorcised redhat9, an ill-timed installation as this particular curse damned itself in favor of fedora days after I installed, I had to pick a sexy new distro to play with…so what else, but go with little-miss-popular, i.e. ubuntu?

After downloading the ISO twice, burning four CDs at various speeds and orientations to the crab nebula and burning bushes, I got one that installed on my eighth attempt. My kung-fu is the best. So far so good, I am typing on it now, and looking for other fun to put it through its paces. Actually pretty usable for all that it is ancient – gee, maybe you don’t need to gigs of memory to be happy after all.

I also need some better way to get it networked, as I have no wifi card for it, and it is across the house from my hub. Like everyone else I am sure, I have a 50′ ethernet cable around I am using at present, but as I don’t wish to make yet another electrical hazard in my home, this is not a permanent solution…

So my brother, an aspiring evil scientist, plottin…

So my brother, an aspiring evil scientist, plotting to take over a flat of his own, has relocated to the land of golf, sheep, and men in skirts. He too has caught the blogger-flu, and now reports from Mighty Reason.

The real question is how much to extort from him in order to prevent me telling mom his new URL. Of course, there is the efficacy of mutually assured destruction . Hmm. I’ll have to find another means to extort the secrets of his evil plans from him.

WLST fun

I’ve been having some fun of late with BEA’s WLST tools. I’m using 8.1 so the fun is that there are 2 versions, one online (while connected to a running admin server or instance), and one offline for doing configuration and creation of instances much as you would through the configuration wizard application.

So here’s the fun – it’s jython based, but the tools start their own interpreter by default, but if you want to, you can create an ini file so you can import WLST as a module into a regular jython script.
But, for whatever reason, the offline version does not work for this…you always have to run the wlst offline class as the interpreter. I am testing a workaround, which since it is not particularly well documented, I am not quite ready to release into the world, but I am hopeful :)

So here in covention land, I beheld some weirdness…

So here in covention land, I beheld some weirdness.

First off, faneuil hall has been a great for seeing big media, especially with MSNBC stationed there. They are not all my favorites – I watch CNN much more – but still amusing.

Of that crew, I got to see Joe Scarborough (not that exciting) and Tom Brokaw (very cool).

Tom was actually a couple of blocks away, talking on his cell, and on his own walking around down town and trying to keep a low profile. I almost didn’t recognize him with his wind blown hair, but talking into his cell phone was a dead give away – that voice cannot be missed.

More fun than celebrities are the regular folks out to make a statement. One convertible promoting voter registration is rolling around with effigies of the candidates propped up in back. I don’t think they’ll be getting into the carpool lane, but clever none the less.

Also on the T I stood next to a woman in medical white carting around a massage chair – her plan being to support the conventioneers (Californian in particular) by offering free massage.

A less positive message was the site of 3 billboard sided trucks touring downtown and quincy market. The bill boards were blown up pictures of aborted late term fetuses – the kind of abortion where the fetus is broken up into pieces when removed. The pieces had been positioned to once again resemble a small baby (though not so small on the side of a truck) – which oddly enough is part of the procedure, so that the doctors can be sure the entire fetus was removed.

Look, I’m pro-choice, so take my views how you will, but those billboards are just gross. At the same time, there are very few medical operations I would want to see blown up and displayed on the side of a truck touring the food court where I am eating. I wouldn’t want to see a gall bladder or appendix after it had been removed, but that doesn’t make me want to ban appendectomies; it just means I’m too squeamish to be a surgeon. There are pictures you could take of the most vital and life saving procedures, including birth itself, that I just do not want to see 10 feet tall and moving down the road while I am eating.

Also amusing is the relatively common presence of supporters for LaRouche.

I have found his pamphlets all over the place.

And finally, my run in with a Nader-phile. Sitting in the Park T station, chatting with a friend, a Nader support tentatively asked if we were registered voters. We explained we were both registered democrats, and would both be voting for Kerry. She happily and helpfully explained we could still sign the petition to get Nader on the MA ballot. In a moment of great restraint, I managed to say only “I would prefer not to”, rather than ripping the clipboard from her hands and shredding it and the republican-aiding signatures while she watched. But I would never subvert the democratic process that way – I’m just tempted.