There was a thread here awhile back on AOL (Aspect Oriented Programming)

http://aspectr.sourceforge.net/

that may be a useful starting place for what you want to do.
-- 
Quantum Mechanics: The dreams stuff is made of