A few weeks ago I was wondering how you get Spring to inject an existing bean that I'd instantiated myself.
I'm trying to integrate our JUnit concurrent test runner with Spring's SpringJUnit4ClassRunner, and while plumbing the depths of the relevant spring code, I came across this:
public void inject(ApplicationContext context, String beanName, Object bean, int autowiringMode) {
AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory();
factory.autowireBeanProperties(bean, autowiringMode, false);
factory.initializeBean(bean, "bean name");
}
inject(bean, "myBean", appContext, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
Simple!
Wednesday, 19 May 2010
Tuesday, 13 April 2010
Ill-Advised Hibernate Mapping Quandary
I'm wondering if this is possible:
class Idea {
Collection primaryTags;
Collection secondaryTags;
}
class Proposal {
Collection primaryTags;
Collection secondaryTags;
}
Mapped to:
CREATE TABLE (
IDEA_ID VARCHAR(36), /* Foreign key */
PROPOSAL_ID VARCHAR(36), /* Alternate key */
TAG VARCHAR(100), /* Whatever was in the String */
TAG_TYPE VARCHAR(9) /* 'PRIMARY' or 'SECONDARY' */
);
I'm thinking.. no. My problem is that I can't see a way to get Hibernate to take care of the TAG_TYPE column - a value that exists in the database, and must be inserted whenever new rows are inserted, but has a value specific to the domain collection whence it came.
Hibernate supports computed properties, but those exist on the domain side, and not in the database. I want the opposite! :-)
class Idea {
Collection
Collection
}
class Proposal {
Collection
Collection
}
Mapped to:
CREATE TABLE (
IDEA_ID VARCHAR(36), /* Foreign key */
PROPOSAL_ID VARCHAR(36), /* Alternate key */
TAG VARCHAR(100), /* Whatever was in the String */
TAG_TYPE VARCHAR(9) /* 'PRIMARY' or 'SECONDARY' */
);
I'm thinking.. no. My problem is that I can't see a way to get Hibernate to take care of the TAG_TYPE column - a value that exists in the database, and must be inserted whenever new rows are inserted, but has a value specific to the domain collection whence it came.
Hibernate supports computed properties, but those exist on the domain side, and not in the database. I want the opposite! :-)
Monday, 12 April 2010
This blog has moved
This blog is now located at http://blog.trilemma.com/.
You will be automatically redirected in 30 seconds, or you may click here.
For feed subscribers, please update your feed subscriptions to
http://blog.trilemma.com/feeds/posts/default.
Monday, 2 November 2009
Giant Spider Costume
Each Hallowe'en, I get the urge to do something more interesting than just giving out candy and taking our kids around the block - wouldn't it be neat to have some scary street theatre going on? Imagine a ghastly wagon drawn by a team of drooling quasimodos in straight jackets, clanging an iron bell, wailing in agony and despair!
I wasn't quite that ambitious this year, but the spirit of Hallowe'en did move me to make a giant spider costume!
The main thing I wanted was the sense of independently moving legs. Not dangling legs, but legs that actually walk. I wondered if I built ski-like structures attached to my feet, I could use my legs to control four of the spider legs, and my arms to control the remaining four.
After testing a prototype using two paint-roller handles I had at home, I was very encouraged. I went to Home Depot and bought myself sixteen 48" of them (which cleaned out Home Depot!). Paint-roller handles are thin metal tubes, coated with a laminate that takes paint nicely. Tou can saw and drill through them easily, but they're strong, and most importantly they're light enough that they don't stress the home-made hinges I was relying on.
I then bought a second-hand set of hockey shoulder pads - a set with nice, large plastic shoulders I could screw into.
Actually, making the holes in the hockey pads was the most dangerous part! The synthetic fabric inside the shoulder pads can wind around the drill bit once you punch through the hard exterior. SNAP! Off to to the hardware store again to replace the drill bit.

The front and back legs were attached using hinges, to keep them in a vertical plane. The main problem with bent-knee designs is keeping the knees from falling sideways - which works okay for the "pile of spaghetti" costume, but not so well for a functioning spider.

The middle pair of legs on each side would be controlled by my arms, so I made universal hinges out of a loop of clothesline wire. Clothesline wire is fantastic, but definitely wear gloves. I duct-taped an old pair of sneakers to the bottom skis, and made a few wobbly laps around the basement.

The clothesline wire came in handy in several other places - creating the connection between the skis and the front/back leg pairs, and as flexible connectors for the handles to control the side-leg pairs.

To decorate the legs, I bought two thicknesses of pipe-insulating foam, and duct taped the heck out of it, then spray painted it in a mottled pattern.
Everyone was surprised that the spider wasn't going to be black, but I wanted as much contrast between the spider's legs and my own body as possible.

The head/body and abdomen were made out of inexpensive chicken wire, wrapped in plaster cloth. Chicken wire is a bitch to work with, especially if your shears are rusty, but it bonds to itself nicely and lets you make great volumes.

I'd planned to do three coats, but I settled for two in most places, with special reinforcement around the neck and other weight-bearing areas.

As soon as I got the eyes on the head, my six year-old refused to be in the same room as it. Since I was going to be lurching after her all night on Hallowe'en, I figured she ought to give it a cute name to help her not be afraid of it. She suggested, 'Bloodie'.

Walking around the house with my mask on, it became apparent that there wasn't nearly enough air flow. The neck seal was nice and tight, and the mask has a tendency to fill up with warm exhaled air. After getting a bit dizzy, I realized I could manage it by deliberately blowing out of the mouth-hole, which would cause fresh air to come in around the edges.
The pedipalps are are dollar-store plastic gourds!
As late as Saturday afternoon, I had yet to try all three pieces together. I could just about get the legs on by myself, but I needed help for the other pieces. As the clocked ticked down to trick-or-treating time, my construction got more and more improvised.
The abdomen was held on by a garrotte-like loop of clothesline wire, which I kept off my neck by passing it through a luggage strap that I fastened around my chest.

The head was then fastened on using a combination of clothesline and bungee cords. One problem was that the abdomen hung down limply like a backpack, instead of sticking straight out - we tried some last-minute engineering but we couldn't make it work in the twilight, so I went out droopy!
As I was sealed in, I got a brief spell of claustrophobia. The abdomen pushed the head far forward, so all I could see was a patch of ground directly in front of me - only a foot or so past my forelegs.
I would need a spider-herder! Fortunately I had a couple of volunteers, my wife (who seems to have escaped the evening without being in a photo) and my sister-in-law, Julain:

Looking at this photo now, I realize her make-up job was way more hideous than my spider! She looks like she's possessed by the ghost of Quentin Crisp. *shiver*

I laugh when I see this photo, the caption ought to be, "Middle-aged weirdo dresses up to hiss at your children." I guess the effect was much better in person because Hallowe'en night itself was a blast.
People kept stopping us to take photos of us, or have their friends take one of them with us, and a couple of cars were nearly rear-ended.
That made up for the fact that walking around like this is like trying to manage two sets of ski equipment at the same time while working out in a sensory deprivation tank. Just crossing the road was an act of faith in my handlers. I could see my legs light up in the car headlights, but very little else!
I tripped several times on the sidewalk, but fortunately the only fall was during the test run in the afternoon. (Avoid grass. And curbs.)
Fortunately I could hear the shrieks and laughs of the other passers by, which was a lot of fun. All in all a great success!
I wasn't quite that ambitious this year, but the spirit of Hallowe'en did move me to make a giant spider costume!
The main thing I wanted was the sense of independently moving legs. Not dangling legs, but legs that actually walk. I wondered if I built ski-like structures attached to my feet, I could use my legs to control four of the spider legs, and my arms to control the remaining four.
After testing a prototype using two paint-roller handles I had at home, I was very encouraged. I went to Home Depot and bought myself sixteen 48" of them (which cleaned out Home Depot!). Paint-roller handles are thin metal tubes, coated with a laminate that takes paint nicely. Tou can saw and drill through them easily, but they're strong, and most importantly they're light enough that they don't stress the home-made hinges I was relying on.
I then bought a second-hand set of hockey shoulder pads - a set with nice, large plastic shoulders I could screw into.
The front and back legs were attached using hinges, to keep them in a vertical plane. The main problem with bent-knee designs is keeping the knees from falling sideways - which works okay for the "pile of spaghetti" costume, but not so well for a functioning spider.
The middle pair of legs on each side would be controlled by my arms, so I made universal hinges out of a loop of clothesline wire. Clothesline wire is fantastic, but definitely wear gloves. I duct-taped an old pair of sneakers to the bottom skis, and made a few wobbly laps around the basement.
The clothesline wire came in handy in several other places - creating the connection between the skis and the front/back leg pairs, and as flexible connectors for the handles to control the side-leg pairs.
To decorate the legs, I bought two thicknesses of pipe-insulating foam, and duct taped the heck out of it, then spray painted it in a mottled pattern.
Everyone was surprised that the spider wasn't going to be black, but I wanted as much contrast between the spider's legs and my own body as possible.
The head/body and abdomen were made out of inexpensive chicken wire, wrapped in plaster cloth. Chicken wire is a bitch to work with, especially if your shears are rusty, but it bonds to itself nicely and lets you make great volumes.
I'd planned to do three coats, but I settled for two in most places, with special reinforcement around the neck and other weight-bearing areas.
As soon as I got the eyes on the head, my six year-old refused to be in the same room as it. Since I was going to be lurching after her all night on Hallowe'en, I figured she ought to give it a cute name to help her not be afraid of it. She suggested, 'Bloodie'.
Walking around the house with my mask on, it became apparent that there wasn't nearly enough air flow. The neck seal was nice and tight, and the mask has a tendency to fill up with warm exhaled air. After getting a bit dizzy, I realized I could manage it by deliberately blowing out of the mouth-hole, which would cause fresh air to come in around the edges.
As late as Saturday afternoon, I had yet to try all three pieces together. I could just about get the legs on by myself, but I needed help for the other pieces. As the clocked ticked down to trick-or-treating time, my construction got more and more improvised.
The abdomen was held on by a garrotte-like loop of clothesline wire, which I kept off my neck by passing it through a luggage strap that I fastened around my chest.
The head was then fastened on using a combination of clothesline and bungee cords. One problem was that the abdomen hung down limply like a backpack, instead of sticking straight out - we tried some last-minute engineering but we couldn't make it work in the twilight, so I went out droopy!
As I was sealed in, I got a brief spell of claustrophobia. The abdomen pushed the head far forward, so all I could see was a patch of ground directly in front of me - only a foot or so past my forelegs.
I would need a spider-herder! Fortunately I had a couple of volunteers, my wife (who seems to have escaped the evening without being in a photo) and my sister-in-law, Julain:
Looking at this photo now, I realize her make-up job was way more hideous than my spider! She looks like she's possessed by the ghost of Quentin Crisp. *shiver*
I laugh when I see this photo, the caption ought to be, "Middle-aged weirdo dresses up to hiss at your children." I guess the effect was much better in person because Hallowe'en night itself was a blast.
People kept stopping us to take photos of us, or have their friends take one of them with us, and a couple of cars were nearly rear-ended.
That made up for the fact that walking around like this is like trying to manage two sets of ski equipment at the same time while working out in a sensory deprivation tank. Just crossing the road was an act of faith in my handlers. I could see my legs light up in the car headlights, but very little else!
I tripped several times on the sidewalk, but fortunately the only fall was during the test run in the afternoon. (Avoid grass. And curbs.)
Fortunately I could hear the shrieks and laughs of the other passers by, which was a lot of fun. All in all a great success!
Tuesday, 16 June 2009
Unbelievably Good Banana Curry
I ad-libbed a curry yesterday, and the leftovers were so good today I nearly ate my wife's portion. It's a sweet, very mild curry - which was great for our kids. Adding the banana is something my father does!
Here's the recipe as best I can remember it:
For a vegetarian version, I usually replace the meat with chick peas (man, I love chick peas) and immediately after adding the tomato I take a wand blender and blend the chick peas, zucchini, onion and tomato until some of it is pureed (makes it nice and thick) but there are still identifiable bits in it.
Here's the recipe as best I can remember it:
- Fry 1lbs ground chicken or turkey until cooked, set aside;
- In a pot, fry 2 medium onions, 1 zucchini until cooked;
- Add spices, allow them to roast for a minute or two:
1.5 tsp curry powder
1 tsp turmeric
a pinch of cinnamon - Add the remaining ingredients:
796mL can of diced tomatoes
the cooked meat
2/3 of a medium banana, chopped
1/4 cup dried currants - Bring to gentle boil, then reduce heat to simmer a bit;
- Add salt, cayenne pepper to taste.
For a vegetarian version, I usually replace the meat with chick peas (man, I love chick peas) and immediately after adding the tomato I take a wand blender and blend the chick peas, zucchini, onion and tomato until some of it is pureed (makes it nice and thick) but there are still identifiable bits in it.
Monday, 18 May 2009
The Zero-Prep Scavenger Hunt for Kids
We were trying to decide what to do with the kids today when it occurred to me that it would be fun to have a scavenger hunt. The problem was that I hadn't prepared anything ahead of time, and the kids were already antsy enough that there wasn't time to do anything.
So I faked a break-in.
I kidnapped one of Morgan's toy mice, grabbed a handful of furniture from its house along with it, and stuffed them into my jacket pocket. Leaving a few telltale items sprinkled on the porch, I called Morgan down to investigate.
The star of the day's entertainment was our cheap electronic stud finder, which I claimed was a toy detector. It has green and red lights, it makes an authoritative-sounding beeping noise, and a sneaky grownup can control when it goes off by surreptitiously sliding a finger behind it while it's on.
Aiming the toy detector at various parts of our neighbourhood, we quickly determined that the stolen toys had been taken in the direction of ... the park!
We came back in to get sweaters and snacks for the excursion. Morgan knew something was up; she's nearly six, old enough to innately grasp the difference between reality and Daddy's silly tricks, even if she is still sometimes confused about where the border is.
Once she was satisfied that there was fun to be had, however, she was willing to suspend her disbelief, and eagerly added some decorative bedding to the tupperware container I had brought to store recovered toys.
Once I had established the premise, the stud finder worked amazingly well. Danielle and I strolled along the path, and I just had to point the thing into the bushes and off the kids went with gusto. Usually this was a bush we had just passed - a side effect of the "zero-prep" aspect of the scavenger hunt.
The kids got so excited by all of this that they started asking passers-by if they had seen the lost mouse. After an hour of this, we came across one couple who had already heard of our search from other park-goers! Isn't it amazing how society rallies around a crisis?
One of the nice things about the zero-prep scavenger hunt is that you can fine-tune things as you go. When the kids are climbing trees, chasing each other, snacking, or otherwise keeping themselves busy, you can just enjoy the scenery. But whenever there's a lull in the action, you can drop a toy or even just bleep the toy detector and off they scurry!
Here's a tip, though: if you drop a toy, remember where you dropped it. After dropping a charming, faux-wicker mouse suitcase in some bushy grass, I forgot to look around for landmarks. Or a decent landmark, at any rate. I could have sworn it was by this distinctive-looking tufty bit.. but then, you're surrounded by tufty bits. It's amazing how fast a lawn can turn on you.
And then, you have to explain why the toy detector suddenly isn't working. "Interference from the bridge?" was the best I could come up with.
Unable to bear the thought that I was personally responsible for the loss of this helpless, cherished toy, I suggested we link arms and walk through the field in a line, like you see on the TV when volunteers are helping the police looking for a body.
The parallel was somewhat uncomfortable, and we got quizzical looks from the joggers and bicyclists whizzing past us as we inched along. But never fear, the suitcase turned up and my "decent parent" status was saved.
Somehow, Morgan never caught on to what I was doing. In the end, she concluded that I must have set up all these toys two days earlier, "On your way home from work!"
My only disappointment was that the kids couldn't operate the toy detector themselves, for obvious reasons. Had they been able to do that, I'm sure we'd have been running full tilt the whole time!
So I faked a break-in.
I kidnapped one of Morgan's toy mice, grabbed a handful of furniture from its house along with it, and stuffed them into my jacket pocket. Leaving a few telltale items sprinkled on the porch, I called Morgan down to investigate.
The star of the day's entertainment was our cheap electronic stud finder, which I claimed was a toy detector. It has green and red lights, it makes an authoritative-sounding beeping noise, and a sneaky grownup can control when it goes off by surreptitiously sliding a finger behind it while it's on.
Aiming the toy detector at various parts of our neighbourhood, we quickly determined that the stolen toys had been taken in the direction of ... the park!
We came back in to get sweaters and snacks for the excursion. Morgan knew something was up; she's nearly six, old enough to innately grasp the difference between reality and Daddy's silly tricks, even if she is still sometimes confused about where the border is.
Once she was satisfied that there was fun to be had, however, she was willing to suspend her disbelief, and eagerly added some decorative bedding to the tupperware container I had brought to store recovered toys.
Once I had established the premise, the stud finder worked amazingly well. Danielle and I strolled along the path, and I just had to point the thing into the bushes and off the kids went with gusto. Usually this was a bush we had just passed - a side effect of the "zero-prep" aspect of the scavenger hunt.
The kids got so excited by all of this that they started asking passers-by if they had seen the lost mouse. After an hour of this, we came across one couple who had already heard of our search from other park-goers! Isn't it amazing how society rallies around a crisis?
One of the nice things about the zero-prep scavenger hunt is that you can fine-tune things as you go. When the kids are climbing trees, chasing each other, snacking, or otherwise keeping themselves busy, you can just enjoy the scenery. But whenever there's a lull in the action, you can drop a toy or even just bleep the toy detector and off they scurry!
Here's a tip, though: if you drop a toy, remember where you dropped it. After dropping a charming, faux-wicker mouse suitcase in some bushy grass, I forgot to look around for landmarks. Or a decent landmark, at any rate. I could have sworn it was by this distinctive-looking tufty bit.. but then, you're surrounded by tufty bits. It's amazing how fast a lawn can turn on you.
And then, you have to explain why the toy detector suddenly isn't working. "Interference from the bridge?" was the best I could come up with.
Unable to bear the thought that I was personally responsible for the loss of this helpless, cherished toy, I suggested we link arms and walk through the field in a line, like you see on the TV when volunteers are helping the police looking for a body.
The parallel was somewhat uncomfortable, and we got quizzical looks from the joggers and bicyclists whizzing past us as we inched along. But never fear, the suitcase turned up and my "decent parent" status was saved.
Somehow, Morgan never caught on to what I was doing. In the end, she concluded that I must have set up all these toys two days earlier, "On your way home from work!"
My only disappointment was that the kids couldn't operate the toy detector themselves, for obvious reasons. Had they been able to do that, I'm sure we'd have been running full tilt the whole time!
Tuesday, 12 May 2009
Subscribe to:
Posts (Atom)
