Session

Metaprogramming Java with HiveMind and Javassist

Howard Lewis Ship, Independent Software Consultant, Tapestry World Domination, Inc.

Track: Programming
Date: Wednesday, July 26
Time: 10:45am - 11:30am
Location: D139-140

Everybody wants something for nothing: more functionality, greater robustness, and less code to maintain. Metaprogramming, “code that writes code,” is an umbrella term for a number of techniques for generating some of the code for your application dynamically. It works best on “cookie-cutter” code, the kind you hate to write and maintain, and dread having to test.

Metaprogramming is typically driven by some form of declaration that describes what functionality is desired and where: we'll focus on using Java annotations for this role. We’ll combine that with the use of the HiveMind inversion of control container to provide structure to our code, and the Javassist bytecode library, to extend the behavior of our services at runtime, adding logging, transaction, and security concerns to our services without writing any specific code. Instead, writing meta code, "code that writes code," code that can be written, tested, and maintained just once, and then used in new contexts endlessly!