2 Replies Latest reply on Jun 3, 2005 12:17 PM by Ovidiu Feodorov

    Question on use of aspects and interceptors

    Tim Fox Master

      Hi All-

      Currently we are using standard interceptors to form the client and server side interceptor stacks.

      It's my understanding, that in the world of JBoss AOP, an interceptor is defined as an aspect with a single method public Object invoke(Invocation invocation).

      Some of our interceptors, e.g. the session interceptor or the transaction interceptor intercept calls on multiple method excutions e.g. commit(), rollback(), recover() etc. etc.

      Currently these all end up in the same invoke() method causing us to do stuff like:

      if ("commit".equals(methodName)
      //handle commit
      else if ("rollback".equals(methodName))
      //handle rollback
      else if ("recover".equals(methodName))
      //handle recover

      If we were to implement such interceptors as standard aspects rather than Interceptors we could define different advice for each intercepted method allowing us to get rid of unwieldy if statements like the above.

      I think this could significantly simplify some of the interceptors.

      Do you think this is worth considering?