Hi, On Tuesday, 2012-09-25, Josh Wills wrote: [...] > But this is trickier-- I need to actually subclass Map.Context and > Reduce.Context for this to work. It's straightforward-- we delegate ~ > everything to the underlying Map.Context or Reduce.Context object > w/the exception of the write() method, which gets handled by the > Emitter object. The only catch is that the subclasses need to call the > parent constructor in their own constructors, and the signatures are > different in hadoop 1 and 2.
Can we use a dynamic proxy perhaps? The one from the JDK only works for interfaces, but you could use javassist's ProxyFactory [1] that can create proxies for classes. The API is pretty simple, delegate everything except write() using a MethodFilter and add a MethodHandler for write() that calls your Emitter. Regards, Matthias [1] http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/html/javassist/util/proxy/ProxyFactory.html
