Fried Linksys WRT54G Wireless Router reborn as a Wireless Bridge
My Linksys WRT54G got struck by lightning last year so I purchased a new one. One of the reasons why I bought it was the Linux firmware available in early Linksys models, but unfortunately at the time I made the mistake of buying the V5 which is the VxWorks version. Having replaced it (with the WRT54GL this time!), I decided to put it to use as a wireless bridge only to discover that it does not have wireless client functionality. After a bit of research I found out that some resourceful folks have in fact ported the DD-WRT distro to the lesser-spec V5 routers so with little to lose, I gave it a bash.
Suffice to say, the how-to below is very easy and simple to follow. Less than 30 minutes later I had the Xbox 360 connected to my wireless network via the old Linksys router I am now pondering upgrading the new router to DD-WRT as well - it seems to have a hell of a lot more functionality than what Linksys provides out of the box, and because of its higher spec it can even run Samba, SSHD and other server goodies. Now if it only had a USB port or two, I could think of some pretty awesome uses for it...
WRTrouters.com .:. Guides .:. Upgrade to Linux from VX Works
Simple Machines Forum
I've been running a small HiFi/HT forum for about a year and a half - AVForums - and recently got rather fed up with phpBB's bugs. Just before I spent the bucks on vBulleting, I discovered SMF and thought I'd give it a try. What a nice surprise - clean and logical management interface, easy to install "packages", and a much more modern UI (very similar to vB in fact). Also it appears to be a lot more secure than phpBB - something you really should worry about given the rise in comment spam lately.
In the process of converting my phpBB database (probably due to the fact that I was using phpBBFM and not a vanilla phpBB installation), I encountered some strange errors for which I could find no answer readily. Those included some topic notifications and group permissions which failed to migrate over to the new format. If you have these issues, do not ignore them and just carry on (even though the bulk of the data might seem to have copied). Rather skip that particular section only by editing the phpbb2_to_smf.sql and deleting only the sections that I did not want to import. I went over all the settings (moderators/permissions in particular) in the SMF Admin console afterwards - a lot of the migrated settings are actually redundant and could be deleted. So far I am very impressed and can highly recommend this package to anyone who is running a phpBB instance or thinking of starting their own bulletin board and can't justify vBulletin.
Load balancing with Spring AOP
As we all know, AOP lets you insert arbitrary code at pre-defined program boundaries - like just before method calls for example. One cool side-effect is that you can decide to not make the call at all, or to call a different method instead. Spring's AOP framework recognizes that not all calls will necessarily route to the same target object, and provides the TargetSource interface which can be used in conjunction with dynamic proxies to supply objects on demand, as calls happen. The following is a rather trivial round-robin load balancing that demonstrates how we can distribute the load over any number of Java objects transparently to callers and callees.
Download: Source code including unit tests and examples.
Some ideas for improvement:
- ability to integrate with Commons Pool (for non-reentrant objects) in place of the simple list currently used (extend AbstractPoolingTargetSource?)
- add an interceptor to detect a configurable list of exceptions and automatically remove bad objects from pool
- ability to re-create beans from a prototype definition in the bean factory as needed (similar to the existing PrototypeTargetSource)
Making Spring’s JaxRpcPortClientInterceptor recover from Axis failures
UPDATE 10 July 2008: This issue has been resolved in Spring 2.0.3 and later by introducing a "refreshServiceAfterConnectFailure" property. Unless you are stuck with an older version of Spring, do not use the solution offered below.
The Spring framework includes a very handy class in the form of JaxRpcPortClientInterceptor as part of the Remoting package. This class allows you to treat web services just like any other dependency - configure, create and inject them in your application context XML file. This is quite clever in that you can write code that works against a Java interface and doesn't care about the underlying remoting protocol used.
The JaxRpcPortClientInterceptor class has a "lookupServiceOnStartup" property which lets you defer the WSDL fetching and initialization until the first request is made. This can help you if the server hosting the web service is not up at the time when the port interceptor is being initialized, however it doesn't help if the web service host disappears afterwards or does not become available until after a call is made. It would appear that Apache Axis (which is the actual JAX-RPC implementation used) gets confused quite easily by network failures and so it helps if you re-create the JaxRpcPortClientInterceptor whenever such a failure is detected. However, if you wanted to keep the benefits of IoC, handling these failures could result in a complicated tangle of BeanFactoryAware factories and exception handling code - not exactly what we want after we've seen just how elegant SOAP access can be with a little Spring magic. I found that in some cases I had to redeploy my application after the web service host disappeared for a short period of time - this is unacceptable in a production environment.
The following code uses Spring's own AOP framework to implement a form of failure recovery completely transparently to existing code. This demonstrates the combined power of IoC and AOP quite well - they allow us to modify behaviour without touching the existing code which was not explicitly designed for pure OOP extensibility (see the Open-Closed Principle about that).
The following XML fragment demonstrates the "pure Spring" approach to configuring web service access using Axis:
And here is the reworked example which makes use of the custom TargetSource:
Source code: