Coca-Cola Colab: featuring Seether, Collective Soul, Metallica
Yesterday we went to see this concert thrown together by Coca-Cola and local radio 5fm. After the usual parking difficulties, massive crowds, lack of hydration, it was just too much awesome to see Metallica live at last. Contrary to what one might expect, they didn't look like they're about to retire any day now at all! The supporting bands were also top notch: I was quite surprised by Collective Soul which I didn't really know from before.
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)
