0 Replies Latest reply on Aug 3, 2007 11:31 AM by Flavia Rainone

    Specification of the Exception on After-throwing and finally

    Flavia Rainone Master

      This thread is about the design of task http://jira.jboss.com/jira/browse/JBAOP-388.

      I just couldn't come up with a good approach to implement this task.

      Let me show why.

      First, I think the specification of the exception would have to do with the pointcut matching, because it does affects selection of whether that after-throwing advice will be bound to a specific joinpoint or not. If the joinpoint does not throw that type of exception, we are not calling the advice. But, besides, this information is also part of the advice matching algorithm itself. I need to validate the type of exception the advice is receiving.

      After going through these first thoughts, I noticed it would be a bad idea adding this to pointcut matching, and decided to do the matching on the advisor generation algorithm. For that, I need to pass this info along with the advice factory created. And notice this will affect all types of advices and weaving modes, because the advice factory is used regardless of the advice type and weaving mode. So, I would have to add a field to AdviceFactory, and this field will be used only in case it is an after-throwing or finally advice, and only if the user specified the exception type.

      On the other hand, if we just do a matching on the type of the exception that the advice catches, we would get rid of the design problem, and the algorithm would be concentrated on the advice.annotation package and the JoinPointGenerator class only. I started considering this approach after reviewing all classes I would have to edit using the previous approach.

      Any thoughts? If the first solution is considered better than the second one, any hint on a better design is more than welcome :)