override - Listening for when a method is called in a class, and then possibly overriding it (java) -
so, let's have 2 classes, foo1 , foo2, in separate library.
foo2 class instantiated, , cannot correctly reinstintate subclass override method in foo2.
is there way can listen method called in foo2, , possibly cancel execution of said method, , there create method. understand if i"m saying confusing, can :).
class foo{ void x(){ if (foo2.x2().called){ //do stuff } } } class foo2{ void x2(){ //stuff done here... } }
obviously, above code won't anything, simple example of looking for.
if can't somehow subclass foo2 or modify existing lib (in worst case decompile/modify/recompile) use aspectj intercept calls.
you'd want use load-time weaving purpose. check out general documentation load-time weaving here: http://www.eclipse.org/aspectj/doc/next/devguide/ltw.html. it's involved procedure add/configure aspectj though i'd recommend last resort
Comments
Post a Comment