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

  • Target

    Hi,

    I'm currently trying to understand how Spring AOP works.

    I understood what were the therms advice, advisor and pointcut, but I don't understand what is the target...

    I tought that it was the object to wrap, but in this case it's very limited. It can't be that because it would mean that an advisor can't be applied to several classes and methods? only on the target?

    So I still don't understand what is the target in AOP.

    thank for your help

  • #2
    The "target" is in fact the bean to wrap. The advice is applied to the target based on the pointcut.

    I'm not sure why you don't think advice can be applied to multiple classes or methods. Have you looked at the Interceptor interfaces? Once the advice is defined it can be used in with multiple targets.

    Hope this helps.

    Jess

    Comment


    • #3
      Actually no I didn't have a look to Interceptor interface, seems that I have to.

      So one proxy factory is for only one object?

      I read somewhere that potentialy, an advice could be apply to each method of the application... So I suppose that this can be achieve with interceptors.
      But I tought that interceptors was a part of the list of interceptors in the bean factory...

      Thank a lot I'm going to learn more about those interceptors
      Last edited by Chaps; Aug 13th, 2006, 11:21 PM.

      Comment


      • #4
        Originally posted by Chaps
        So one proxy factory is for only one object?
        Its one proxy per object. The most common way to accomplish this is to specify a proxy factory per object. But you can generate many proxies with one factory using one of the AbstractAutoProxyCreator subclass, ie BeanNameAutoProxyCreator.

        I read somewhere that potentialy, an advice could be apply to each method of the application... So I suppose that this can be achieve with interceptors.
        I think you might have your terms mixed up. Interceptors is how advice in Spring is implemented. By contrast AspectJ uses code weaving.

        Comment


        • #5
          Ok!

          But I still don't understand something, isn't it the aim of the poincut to define the criteria to select methods to wrap? And a pointcut contain a ClassFilter, so what is it for if anyway the object will be selected by the proxy creator ?

          I tought that the way of defining objects to wrap was with the pointcut

          Comment


          • #6
            An advisor is combination of a pointcut (which methods to wrap) and advice (what functionality to execute). If you don't specify a pointcut (usually by passing an advice object like a MethodInterceptor) then it uses a default pointcut of all public methods on object to be proxied.

            Comment


            • #7
              Yes I know that, but if the pointcut define the methods to wrap and the classes, wath is the aim of the target?

              Comment


              • #8
                The target is the actual object whose functionality you will execute after executing your various advisors.

                Comment


                • #9
                  Hum I still don't get it :S sorry, I think I'm going to read again the spring reference

                  For me, you define the action to do with the advice, then you define the methods concerned with pointcut. Pointcut allow defining those methods using class filter and method filter, so, the concerned methods could all the methods of the application. or all the methods that match get* and being in a specified package etc...

                  Then I have an advisor, that pull together a pointcut and an advice.

                  I think I'm right until there.

                  then, I have to create proxies. In my mind, just an advisor seems to be enough to know which methods to wrap and what to do.
                  So a proxyFactory ask for a list of advices.

                  But know, I have to define this object "target"... If this object define the wrapped object, then the pointcut become almost useless... if it was defining that all methods of the application were concerned, now it is reduced to all methods of only one class?

                  This is what I don't understand...

                  Sorry for my english it probably doesn't help to understand my problem
                  Last edited by Chaps; Aug 15th, 2006, 03:32 PM.

                  Comment


                  • #10
                    Ok, the target is the object that gets advised. And how do you decide which classes are targetted?, you use a pointcut to do that. So pointcut is a specification that decides which objects get targetted under what circumstances.

                    Comment


                    • #11
                      Originally posted by sabarish
                      And how do you decide which classes are targetted?
                      with the property "target" of a proxyFactoryBean I think.

                      Well there is probably something I didn't understand and I'm currently working on it. It seems that autoproxing is my solution especialy the defaultAdvisorAutoProxyCreator

                      Comment

                      Working...
                      X