0

Is it possible to implement an adapter capable to intercept all inner method invocations inside main method? If we have this class...

class Zombie {

  private Grave grave = new Grave();

  public void kill(Integer zombieId) {
    grave.dig(zombieId);

    grave.put(zombieId);

  }
}

installing the listener for "kill" method would intercept call for "dig" and "put" methods of a "Grave" class. If this is possible, some code would be great too.

Thanks.

Nedo
  • 627
  • 1
  • 10
  • 20
  • There are a number of ways of doing this such as byte code injections, AspectJ, Proxy objects. However, if this is your own code, I suggest doing it in Java without any magic. ;) – Peter Lawrey Sep 06 '12 at 10:56
  • I'm working on a project, mostly Spring based, so I'm aware of AOP techniques ;). Around advices would work, but as long as I know it cannot inspects any method inner instructions. – Nedo Sep 06 '12 at 11:03

1 Answers1

0

I figured out this can be done by attaching Spring CustomizableTraceInterceptor interceptor to BeanNameAutoProxyCreator :)

Nedo
  • 627
  • 1
  • 10
  • 20