Announcement Announcement Module
Collapse
No announcement yet.
AOP implementation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP implementation

    Hi,

    Thank you Spring team for the great work. I am really diggin your code. I am relatively new to AOP. I follow your implementation in aop package up to the point of getting all the bean, advices and interceptors in bean container like ProxyBeanFactory. However, I do not see how the interceptors and advise get applied. And how the MethodInvocation is linked to PointCut. Can anyone clarify the flow how things are tied up together? And Rod, would you be writing a book about AOP implementation? I will be among the first to buy. Thanks.


    Don B.

  • #2
    Don

    The interceptor chain is applied by either JdkDynamicAopProxy (for J2SE dynamic proxies) or Cglib2AopProxy, both in the org.springframework.aop.framework package. This proxy is configured by the AdvisedSupport object it refers to, which supplies the advice chain etc. (ProxyFactory and ProxyFactoryBean extend AdvisedSupport).

    A MethodInvocation object flows through the interceptor chain, with the pointcut being evaluated for each piece of advice. An Advisor contains both pointcut and advice. (An advice is an object that can execute if the pointcut fires. An Interceptor is an example of an advice.)

    There's some optimization in that pointcuts can often be evaluated just once, when the proxy is created, but this is the basic concept.

    There's a fairly detailed chapter about AOP in "J2EE without EJB". I'm also writing a very detailed AOP chapter for the forthcoming "Professional Spring Development".

    Rgds
    Rod

    Comment


    • #3
      Thank you for your reply, Rod. I will take a closer look at the code and follow your explanation. I have your first book and the J2EE without EJB is on its way. Really great work. I would like to thank you as many times as you can take. No joke.

      Comment


      • #4
        Hi Rod,
        Originally posted by Rod Johnson
        Don

        The interceptor chain is applied by either JdkDynamicAopProxy (for J2SE dynamic proxies) or Cglib2AopProxy, both in the org.springframework.aop.framework package. This proxy is configured by the AdvisedSupport object it refers to, which supplies the advice chain etc. (ProxyFactory and ProxyFactoryBean extend AdvisedSupport).

        A MethodInvocation object flows through the interceptor chain, with the pointcut being evaluated for each piece of advice. An Advisor contains both pointcut and advice. (An advice is an object that can execute if the pointcut fires.
        As per your statement then the Advisor in Spring should have the PointCut also , but your design have a seperate Pointcut Advisor and Introduction Advisor ? Why is this like that ?

        Regards
        Vicky

        Comment


        • #5
          As per your statement then the Advisor in Spring should have the PointCut also , but your design have a seperate Pointcut Advisor and Introduction Advisor ? Why is this like that ?
          Rod ,
          Can I get some of your time on this . :wink:
          Regards
          Vicky

          Comment


          • #6
            As per your statement then the Advisor in Spring should have the PointCut also , but your design have a seperate Pointcut Advisor and Introduction Advisor ? Why is this like that?
            There are two types of Advisor: those for applying an advice to methods (the commonest case), and those for making introductions to advised objects. The first type is PointcutAdvisor: a Pointcut is required to identify which methods to advice. The second type is IntroductionAdvisor: the MethodMatcher part of the Pointcut interface is irrelevant in this case, hence we only use the ClassFilter part rather than a whole Pointcut.

            Comment

            Working...
            X