Friday, August 21, 2009

Spring and GWT Servlet Instantiation

I'm another person who wants to make a web application that uses Spring (dependency injection) and GWT (RPC and UI rendering).


GWT recommends setting up a servlet to do the RPC by declaring it in web.xml like this.

 <!-- Servlets -->
 <servlet>
    <servlet-name>stockPriceServiceImpl</servlet-name>
    <servlet-class>com.google.gwt.sample.stockwatcher.server.StockPriceServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>stockPriceServiceImpl</servlet-name>
    <url-pattern>/stockwatcher/stockPrices</url-pattern>
  </servlet-mapping>

That way, the web-app container (eg. Tomcat) will construct the servlet object.

Now I want my servlet object to have Spring context beans injected into it.

I could write special Spring-specific code to put in my servlet to do get the Spring application context and find all the beans it needs, but that's cumbersome, and can't take advantage of Spring's autowiring.

I happened to watch Ben Alex, of Spring Security, give a great Introduction to Spring Security talk, where he mentioned that it's hard to give up Dependency Injection just to fit in with the web-app container. So instead of letting the web-app container create the Spring Security filter that one could declare in web.xml, he declares (at around 9'10") a DelegatingFilterProxy in web.xml, and gives it a name "springSecurityFilterChain". The clever DelegatingFilterProxy, when it is started by the container, loads the spring context, finds the bean with that name (ie. the bean called springSecurityFilterChain), and uses it as the actual filter.

I want to do the same thing, but instead of filters, I want to do it for the servlet itself. Luckily, Spring provides a class to do that: org.springframework.web.context.support.HttpRequestHandlerServlet. All I have to do is replace the servlet-class line in the web.xml above with that HttpRequestHandlerServlet. Then, when the servlet is required, the HttpRequestHandlerServlet will look in the application context for a bean called "stockPriceServiceImpl". To make sure we have one of those, the applicationContext.xml needs to include something like:

<bean id="stockPriceServiceImpl" class="com.google.gwt.sample.stockwatcher.server.StockPriceServiceImpl"/>
There are two problems with this. The first one is that the HtpRequestHandlerServlet can only hand requests to HttpRequestHandler objects. Now we know that the stockPriceServiceImpl is a servlet, and it can handle these requests, but it doesn't use the right method names. Now I should really make a new version of the HttpRequestHandlerServlet that can hand off requests to a javax.servlet.HttpServlet or even to a javax.servlet.GenericServlet. The GWT RemoteServiceServlet extends these two standard java classes. But that's for another day. For today, I simply made my StockPriceServiceImpl class implement HttpRequestHandler and added the following method:

@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response) 
                         throws ServletException, IOException {
  service(request, response);
}

Now, spring is able to construct the stockPriceServiceImpl, but it still doesn't work. There's a NullPointerException that happens. I delved around in the source, and discovered that the stockPriceServiceImpl needed to locate its servletContext, so that it could load various serialization files. When the web-app constructs a servlet, it initialises it with the appropriate context. When Spring initialises it, it doesn't - by default. But, we can tell spring that we want it to do so, if the object implements ServletContextAware. So, I added that as an interface that the stockPriceServiceImpl implements, and then had to implement the setServletContext method. Unfortunately, the ServletContext object to be passed doesn't have a convenient constructor (it's an interface). So I created an anonymous class to provide the context, like this:

public void setServletContext(ServletContext servletContext) {
  final ServletContext context = servletContext;
  try {
    init(new ServletConfig() {
      @Override
      public String getInitParameter(String name) {
        return null;
      }
      @Override
      public Enumeration getInitParameterNames() {
        return null;
      }
      @Override
      public ServletContext getServletContext() {
        return context;
      }
      @Override
      public String getServletName() {
        return null;
      }
    });
  } catch (ServletException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}

And now it seems to work. (It took me long enough to get here that I thought I'd better jot down what I did!) Next step, as I said, is to see if I can adapt HttpRequestHandlerServlet so that it can just instantiate a javax.servlet.GenericServlet directly without having to add those dodgy bits.

Thursday, August 13, 2009

Mothers Milk

First Drop wines is a fairly new Barossa "virtual" winery. The comic-style label for 2007 Mother's Milk caught my eye at The Wine Emporium the other day, and I decided that it was worth a try. James Halliday gave it 4.5 stars, and I can see why. It's definitely fruit driven: soft and smooth, but with a medium body, and that all important cigar complexity. The length is quite good too. Dangerously easy to drink! I'll have to try a side-by-side tasting against the 2007 Jim's Hill...

Saturday, August 1, 2009

Shiraz Expo

You'll remember that I discovered Pol Gessner champagne was available at Dan Murphy's. Given that Hamilton is a little out of the way, you might be wondering how I found out. Well, there's a good answer: I was attending the 2009 Shiraz Expo there back in early May.

I thought it would be good to record for posterity some of the 30-odd Shirazes that I tasted there, and what I thought of some of them. First of all, let me mention the expensive ones, in no particular order:
  • Penfolds Grange (2004) ($570) - exceptionally full bodied, cigar/tobacco tastes; very long.
  • Kays Amery Block - deep fruity liquorice, no smoke/pepper.
  • Elderton Command - powerful, but limited back palate length.
  • Grant Burge Meshach - smooth, full bodied spice.
  • Penfolds St Henri (2001) - dry, low tannin, not particularly fruity. I don't get this wine.
  • Penfolds RWT - Full bodied to chewy! smooth with fruit/tannin balance, not too spicy.
  • Saltram No. 1. All spice, where's the fruit gone?
  • Wolf Blass Platinum - very long.
  • BVE E&E Black Pepper - Nice complexity, again not too spicy
  • Eileen Hardy - too light... no body.
  • Henschke Mt Edelstone Good long tobacco & spices.
  • St Hallett Old Block - Nice smoky/leathery flavours with good mouth filling body.
  • Annies Lane Coppertrail. Light bodied but smooth.
Some of the under-$40 ones that I'd like to taste again:
  • Henschke Keyneton Estate - balanced & fruity.
  • Wolf Blass Grey Label - Chocolate & vanilla hints, medium body, with good length.
  • BVE Ebenezer - Smooth, balanced, medium bodied peppery, with front palate length only.
  • Leasingham Bin 61 - Light bodied.
  • Brokenwood - Syrupy plums with good length and balance.
  • St Hallett Blackwell - Smoky and smooth, medium body.
  • Glaetzer The Bishop - Smooth with well-integrated oak, quite a good length.
Some cheaper (under $20) ones that are probably good value, but hard for me to judge effectively with the other competition.
  • Charles Cimicky The Trumps - a medium-weight peppery Barossa shiraz.
  • Richmond Grove Barossa
  • Thorn Clark Sandpiper
 I only tried a couple of cheaper WA wines (Vasse Felix and Cape Mentelle). While I like Cabernets from that side of the country, particularly Margaret River, on this occasion the Shiraz didn't rate.

I look forward to attending another Dan Murphy Shiraz Expo. The value for money was excellent (it was free!), and it was great to find a place with such a big variety of wines. I just need to get to the Wine Emporium in the valley now to compare.

Spring and Champagne, Bordeaux, Clare, Yarra

There's a couple of things to talk about. I'm getting frustrated trying to get the latest spring/hibernate/jpa libraries to work together to do the whole hbm2ddl business. It seems to delete the tables for my entities, instead of creating them. I'll try the Spring milestone libraries next instead of the MyEclipse bundled 2.5 ones.

But probably more importantly, I wanted to let you know about some Champagne. Now Joanna will tell you that I'm really not a Champagne person. In fact I'd rather have a Rockford Basket Press than the (sparkling) Black Shiraz that seems more popular. When we have méthode champenoise sparkling whites here in Australia, I struggle to find much in them. But I do remember about 10 years ago my Auntie Barbara shared a Pol Gessner with us, and it was a revelation: a yeasty, almost nutty flavour with a very creamy smooth bead. Now the memory may have aged well, and it was a pleasant dinner, so I may be raving a little too much about it. But I've always thought that I'd buy some more if I saw some. And now I've discovered where I can get it - it's exclusively imported by Dan Murphy. They're not local, but my local Vintage Cellars people advised me to try a Dumangin Vintage 2000 or a Gimonnet Brut (both premier cru grand classe) which were only slightly out of my price range. But a birthday and good loyalty-scheme-points seemed like a reasonable excuse, so I indulged.

We tried the Dumangin the other night, at our local restaurant "Plum" for a late birthday celebration. The food was pretty good - my pork belly (no, the one on the plate!) was not as succulent as I might have hoped - but the champagne did take me back. I'm not quite sure that the flavour was as strong in the nutty line. Perhaps "biscuity" as the salespeople suggested was a more accurate description. Maybe I need to look for blanc de noirs with more pinot. But the creamy yeast was there, and perhaps that made it worthwhile.

We also shared a 2005 Chateau d'Aurilhac from the Haut Médoc in Bordeaux. It was my first Bordeaux for a while, and we saw the smooth subtleties, complexities, and some length. I find it's chiefly the subtlety that distinguishes these French wines from the "blockbuster" Australian ones. The wine complemented my pork, and by all accounts the beef and duck too, so I'm quite happy with that one. There's another bottle waiting for the next occasion. (Another positive review)

A few days later, we had another family meal with a lamb stew, and so another Cabernet-based wine was called for. I decided to try a contrasting Clare Valley Kilikanoon Blocks Road Cabernet Sauvignon. While there was still smoothness, the wine was certainly very fruit-driven and had much stronger flavour than the Bordeaux. I'm not sure that the violets (as advertised on the label) were there, but I admit I'm not particularly familiar with the scent anyway. The berries were there, with a very slight hint of liquorice. The length was good, but not exceptional. With various driving commitments to think of, we spread the drinking pleasure over two nights. The vacu-vin seems to have preserved the quality nicely.

And just to make you think that my life really is centred on wine (and to save me from trying to remember details for another post), I'll also mention that we matched a roast pork with a Yarra Valley Sticks Pinot Noir. Now I'm not in the Sideways class of pinot fans, but Sticks, for about $20, seems to provide a reliable if not earth-shattering one. There's a slight tannic savour in there that distinguishes it from the cheap strawberry-cordial flavours of some others. In summer, it would definitely need cooling, but we found that on our 5°-25° Brisbane winter days a room temperature was just right.

Cheers!

Monday, December 15, 2008

Bordeaux

When we first tried some French wines, I had my doubts. I thought that it might be a whole year of rather academic tastings, rather than particularly deliciousment. But it's struck me (on the eve of our departure from the Northern Hemisphere) that I am quite well acclimatised, and rather attached to the prticularly scrumptious Bordeaux wines.

I'm so happy to have had the chance to try wines from a number of regions, including Languedoc/Roussillon, Beaujolais, Vallée du Rhône, Val de Loire, Champagne, and Bordeaux. When I left Australia, I was particularly attached to Shiraz, and therefore expected that Rhône might be the most interesting wines. And maybe I haven't given them a fair go - trying perhaps only half a dozen, with little expert advice. I've tried at least a couple of dozen different Bordeaux wines, and I've taken to them. Wayne McCarthy at the Avant Garde cave in Margaux has provided some excellent advice (supplying us a dozen by post), and I'm afraid I'll miss these ones when we get back to the Great Southern Land. I had initially thought I might describe the wines as I tasted them, but given the likelihood of pieces of paper going astray, and the possibility that I'll enjoy the wines too much to write about them while I can remember the details, I thought it might be worth writing down here.
  • Ch. Tour Haut-Cassan (Médoc) 2001 (€16)
  • Ch. Penin "Les Cailloux" (Bordeaux Superieur) 2005 (€12.50)
  • Ch Citran 2004 (Haut-Médoc) 2004 (€13,40) I shared this with some people at work on my last "Rumour: Wednesday Pub Lunch" at the Winterbourne Arms. Smooth.
  • Ch Haut-Bergeron (Sauternes) 2002 (€24)
  • Ch. Charmail (Haut-Médoc) 2004 (€16)
  • Ch. Poujeaux (Moulis) 2004 (€20.50)
  • Ch. Deyrem Valentin (Margaux) 2002 (€16)
  • Ch. Des Graviers (Margaux) 2004 (€13.40)
  • Ch. Moutte Blanc (Bordeaux Superieur) 2002 (€8.70)
  • Clos de Bigos (Margaux) 2005 (€16.90)
  • Ch. Potensac (Cru Bourgeouis Exceptionnel, Médoc) 2004 (€16.50)
  • Ch. La Galiane (Margaux) 2003 (€13.20)
Tonight, we're indulging in the Château Potensac, and finding it particularly delicious. It's very well balanced, fruity and smooth, with lengthy tannins. It doesn't have the syrupy/jammy tastes that I remember (perhaps inaccurately) from some of my favourite Australian wines - like a Peter Lehmann Stockwell, or a Leasingham Classic Clare Shiraz. But the complexity is there.

We've packed a few wines (within our duty free limit) to take back home. But not as many as I feel would do justice to Bordeaux.

So has my palette changed? Or will I find when I get back to Australia that I really do like those big Barossa shiraz wines (e.g. Rockford Basket Press, Wolf Blass Grey Label) more than these French ones? Time will tell!

Saturday, November 29, 2008

The Bourne Identity

I've been driving between Malvern and Salisbury a few times recently - a 100 mile journey. I've noticed a series of sets of small villages on the way:
  • Duntisbourne Abbots, Duntisbourne Leer, and Duntisbourne Rouse
  • Ogbourne St Andrew, Ogbourne St George, and Ogbourne Maizey
  • Collingbourne Kingston and Collingbourne Ducis
  • Winterbourne Dauntsey, Winterbourne Gunner, and Winterbourne Earls
I think it's interesting that such a high proportion of villages along my route have this pattern in their name. My highly authoritative wikipedia research reveals that the suffix "-bourne" typically indicates a stream. So the Ogbournes are on the River Og, and a Winterbourne is a river that dries up in the summer. Apparently a Mr Dunt had a stream, and Cola's people (?) had a stream too. The tautologous River Bourne flows through the Collingbournes and Winterbournes.

I suppose that these are a variation of the famous "Stratford upon Avon" and "Upton upon Severn" style (although perhaps "Upton under Severn" is more frequently appropriate). That reminds me of a masters thesis I saw when browsing for a few minutes in the Birmingham University Computer Science Department library: a survey of English towns whose names end in -ford. I think it may have been mis-filed.

Other interesting place name points:
  • The Defence research organisation near Salisbury is accessed via Winterslow Road. This statement is true whether you are referring to Salisbury, Wiltshire UK, or Salisbury, South Australia.
  • I also drive past Newton Tony and Stratford Tony. I can't offer any insight into these names at the moment.
  • Some of the place names are quite evocative: Shady Bower, Old Malthouse Lane.

Thursday, November 6, 2008

Thai Sarocha - Salisbury UK

I'm doing some stints in Salisbury for the next little while. Reminds me of my time in Adelaide...

But the thing I wanted to write about tonight was the food. I went to a satisfactory Thai restaurant last night, and decided that there were others that I should also try. My technique involves looking at a Google Map one night, and then seeing if I can get to the place the following evening after work. Now I actually spotted the Rai d'Or this morning - I took a slightly suboptimal route from the Cathedral to the bus stop. But while heading for it in the dark this evening, I took another suboptimal route, and came across the Thai Sarocha first.

What a lucky find. I don't think I've had better Thai food since I've been in the UK. I started with the Pad See Iew, special fried flat noodles with pork and mixed vegetables in a sweet dark soy sauce. One of the best parts was the basil. Last night's basil tasted stale and sour. Tonight's was just how I like it - certainly not overpowering, but a bit more than "subtle". I was really happy to find a place that served coconut rice - I have no idea how authentic it is, but I haven't seen it since we left Australia. I get it every time from our local, there. The menu did call it "Thai fried rice with coconut cream", but I think it was steamed. My red curry beef was classified "hot" in the menu, but was ideally mild/medium on my scale. Again, the basil was a highlight. I suppose I could mention that the beef didn't have much flavour of its own, but that's not what you buy a curry for, is it? While on a roll, and having been highly disciplined at lunchtime, I felt I had to try a dessert. It was a steamed banana in coconut milk topped with sesame seeds, with vanilla ice cream. In case you weren't aware, I like coconut even more than basil! I could complain about the undissolved sugar at the bottom of the bowl, and perhaps a lack of sesame, but the whole dish was delicious, and I soaked up every bit. The banana and coconut complemented each other very well, and the vanilla bean flavour in the ice cream was strong enough to match. There were about 10 whites and 10 reds on the wine list, with a couple of each available by the (small or large) glass. Main courses seemed to be mainly around the £7.50 mark, with seafood, specials and steaks higher - up to a max of £14.00. My noodles, curry, rice, and dessert came to £21. I'll be back!

69-71 New Street, Salisbury SP1 2PH.
01722 415 115

Thursday, October 30, 2008

Northeast

We're in York at the moment, on the middle of a 3-night trip to the Northeast. Last night we stayed in Newcastle. It was freezing. We visited many of the attractions, including Fort Segedunum at Wallsend - the eastern end of Hadrian's Wall. We saw some city walls, Gallowgate, several bridges, etc. Dinner was a high-class affair at a chinese buffet.

We looked at the Angel of the North as we left Newcastle for Durham.

In Durham, we visited the Castle, although only briefly: visits only permitted by (too expensive for us) guided tour at a time that didn't suit. We looked around the Cathedral, and climbed the 324 steps to the top of the tower.

Ambling from Durham to York, we drove through Ampleforth, including the Abbey/College - something I'd like to visit properly one day. Chop Gate was also cute.

In York, we spent a few hours at the National Railway Museum, primarily because that's where the York Wheel (competitor to the London Eye) is. We went on a simulator ride as well, covering London to Brighton in 4.5 minutes. Then we dined at the Delhi Spice (allegedly French/Indian/Italian fusion, although no evidence of anything but regular Indian), before checking into our B&B. This was much cosier than our 2 separate self-contained apartments in Newcastle, which tried to look rather posh, but didn't turn out so well. Tonight, we're all in one 4 (plus one) bedroom. But it's fine.

Looking forward to more York experiences tomorrow.

Monday, October 27, 2008

How to buy wine in Bordeaux

Tasting wine in Bordeaux isn't quite like tasting wine in Barossa. In Australia, they know you want to taste the wine, so when you go to visit them, they give you a bunch of wines to taste. But on our visites to many chateaux in Bordeaux, the experience seems to be that you spend an hour being shown around the wine making process, and then you have an opportunity to taste one, two, or three wines. This might help convince opportunistic tourists not to go everywhere and taste everything - but then how do you learn what you like?

There is the Maison du Vin in each commune. They offer various courses, but not (in my experience) educational tastings. You can buy a whole bottle of most wines...

You can try tasting some wines with meals in restaurants. But (at the restaurants/price-brackets we chose) there wasn't a huge variety, and you can't get all the wines by the glass.

The only real option seems to be to go to a bottleshop or in the vernacular, a Cave. The salesmen will offer you a couple of things to taste, and then start pressuring you to buy. If you have a clear idea wof what you want to try, then you may have more luck. We found ourselves buying a couple of bottles just to get out of one place.

The best wine buying experience we had was at the Avant Garde cave in Margaux. Yes, it helped that the owner was an Australian - Wayne McCarthy. They had one wine open for tasting when we went in - it was nice, and we decided we'd buy that one. But Wayne suggested we should choose a dozen to send back to England. In practise, after we specified our budget (approx €15/bottle), he chose a dozen that he said were good value for money and a good variety. The postage to the UK wasn't too expensive (€29) and the wines arrived in good order in their wooden case.

Tonight we opened the first bottle, a 2004 Chateau Poujeaux from Moulis. It's fantastic - decent body, depth, & length! Apart perhaps from the Premier Cru Classe ones that were over €200/bottle, this one (at €20.50) is probably better than all the ones I tasted on the trip. Who knows what influences - the weather, the cooking, relaxing at home - might make the difference. But I'm convinced that Wayne really did help us get great wine at a bargain price.

It's a bit prohibitive to do it from Australia, but if you're in England say, and you wanted a case of delicious Bordeaux wine, I'd suggest emailing Wayne for some ideas and a quote.

For the record, the dozen that we bought were:
  • Ch. Tour Haut-Caussan 2001 (Médoc)
  • Ch. Penin "Les Cailloux"2005 (Bordeaux)
  • Ch. Citran 2004 (Haut-Médoc)
  • Ch. Haut-Bergeron 2002 (Sauternes)
  • Ch. Charmail 2004 (Haut-Médoc)
  • Ch. Poujeaux 2004 (Moulis) - tonight's delight
  • Ch. Deyrem Valentin 2002 (Margaux)
  • Ch. Des Graviers 2004 (Margaux)
  • Ch. Moutte Blanc 2002 (Bordeaux)
  • Clos de Bigos 2005 (Margaux)
  • Ch. Potensac 2004 (Médoc)
  • Ch. La Galiane 2003 (Margaux) - the one we tasted in the Cave.

Cheers!

Saturday, October 25, 2008

Rocamadour

From Carcassonne we explored some cute villages in the Gorges du Tarn: mostly St Chély and Ste Enimie.
 
After crossing the Millau Bridge...

 
...we made it to Rocamadour, a village (or perhaps more accurately, 7 chapels for pilgrims) built into the side of a cliff.

 
We had a little rain during the drive, but it was all gone by the time we arrived at our cliff. Better weather than you could expect for October.
With some more judicious disputes with the SatNav, we made it back to the west of the country the following day, with enough time to take Sophie for a brief walk through St Emilion, before checking the loot in at Bordeaux airport. On this occasion, there was no quibble about the suitcase being 20.7kg - and the wine seems to have come through undamaged.