Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Hooking into Spring weaving

  1. #11
    Join Date
    Aug 2006
    Posts
    382

    Default

    Quote Originally Posted by johras View Post
    Code:
    @Aspect
    public void MyClass {
        @AnnotationMatchingPointcut(MyCustomAdvice.class)
        public void method() {}
    over:
    Code:
    @Aspect
    public void MyClass {
        @Pointcut("@annotation(MyCustomAdvice")
        public void method() {}
    This thread has caught my attention because I have written a couple of aspects that are based on custom annotations. I am intrigued by @AnnotationMatchingPointcut. Unfortunately, AnnotationMatchingPointcut is NOT an annotation. You can't use it that way. I just tried, out of freak hope that it would work, and Eclipse is puking all over that. It appears you can res it up inside an appContext.xml file, but I don't see how to plug it in to @AspectJ.

    So far, I have
    Code:
     	@Around("execution(@my.package.app.annotations.Timed * *(..))")
    	public Object calculatePerformance(ProceedingJoinPoint jp) throws Throwable {
    And yes, I have a unit test to make sure my aspect works and that my point cut works.
    Greg L. Turnquist (@gregturn), SpringSource/VMware
    Project Lead: Spring Python and author of Spring Python 1.1 and Python Testing Cookbook.
    Listen to Pond Jumpers, the international podcast for open source developers.
    These comments are my own personal opinions, and do not reflect those of my company.

  2. #12
    Join Date
    Apr 2008
    Location
    Lomma, Sweden
    Posts
    41

    Default

    Sorry if I was not clear, I did not mean that I am doing that, I meant that
    I would like it to work that way.

    If it worked, it world mean the world to me ;-)
    Since it does not work (and thats reason for this thread), I have been testing to do some stuff with Springs AOP support using a custom BeanPostProcessor to advice my classes which actually works ok but you donīt get it out of the box.

    Using @Aspect, i think your approach is the the one to use, or ("@annotation(my.package.app.annotations.Timed) " ).
    Last edited by johras; Oct 7th, 2008 at 12:02 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
  •