Results 1 to 5 of 5

Thread: Pointcut question

  1. #1
    Join Date
    May 2005
    Location
    New York
    Posts
    3

    Default Pointcut question

    I'm new to Spring AOP and I have a question. The Pointcut interface defines a getClassFilter() method, however, since I've been playing around with AOP in spring I noticed that you always specify a specific target for the Dynamic Proxy to weave your aspect into.

    If this is the case, when will you ever use an implementation of the ClassFilter interface when you can declaratively state which Class you want to apply your aspect to within the beans xml file?

    It seems that you must always declare a target object and slip a proxy in front of it in order to use AOP (ignoring cg-lib). I just can't see how the ClassFilter even has a chance to work when you specifically choose which class to sprinkle with advice in the configuration file.

    Any help on this matter would be greatly appreciated.

    Thanks!
    -J

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    when will you ever use an implementation of the ClassFilter interface when you can declaratively state which Class you want to apply your aspect to within the beans xml file?
    It is needed internally (e.g. see AbstractRegexpMethodPointcut) and you can use it for your own pointcuts definitions.

  3. #3
    Join Date
    May 2005
    Location
    New York
    Posts
    3

    Default

    I'm not sure I understand your reply. I know that I could use a ClassFilter in my own implementation of a Pointcut, however, what's the point (no pun intended) if the factory's xml file is going to specify a specific class for a target to proxy.

    I was doing some reading and although I haven't gotten far enough it seems the autoproxying may explain the use of the ClassFilter since you can have proxies generated automatically and perhaps have them use a "group" of Advisors yet you will want to restrict certain advisors to certain classes. Does that make any sense? I probably have to do more reading -- although I was hoping for a quick answer so I can say, "ahhhhh!".
    -J

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    what's the point (no pun intended) if the factory's xml file is going to specify a specific class for a target to proxy
    You can specify a group of classes and methods. E.g.

    Code:
    <bean class="org.springframework.aop.support.JdkRegexpMethodPointcut">
        <property name="pattern">
            <value>.*foo.*</value>
        </property>
    </bean>

  5. #5
    Join Date
    May 2005
    Location
    New York
    Posts
    3

    Default

    Yes, I think I answered my own question. The ClassFilter really shines when you're autoproxying -- especially when you're autoproxying all your beans you can specify the Advisors of your choice with the Advice/Pointcut pairs where your pointcut would include a ClassFilter because you may not want the autoproxy to target all your beans.

    I find it that most people will not use autoproxying as much as you think which makes the ClassFilter much less important than it may seem when reading about it. I still have a long way to go reading about Spring. I think Rod Johnson and his team have done a wonderful job with this framework.
    -J

Similar Threads

  1. Forgot password (e.g. secret question) using Acegi
    By lowerymb77 in forum Security
    Replies: 1
    Last Post: Oct 16th, 2005, 10:46 PM
  2. HttpInvoker / Serialization question
    By ZeddMaxim in forum JMS
    Replies: 1
    Last Post: Apr 20th, 2005, 05:37 PM
  3. Replies: 3
    Last Post: Apr 3rd, 2005, 04:34 PM
  4. Need Help - Question regarding PetClinic Example
    By spring04 in forum Architecture
    Replies: 6
    Last Post: Nov 17th, 2004, 12:59 AM
  5. Replies: 6
    Last Post: Oct 8th, 2004, 02:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •