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

  • Pointcut pattern not matching

    Could someone please help me by explaining why the following pointcut definitions work/don't work.

    I have written the below code to illustrate the problem in which I have an interface and class that implements the interface:

    Code:
    package com.abc.services;
    
    public interface MyService {
      public String getValue();
    }
    
    package com.abc.services
    
    public class MyServiceImpl implements MyService {
      public String getValue() {
         return "str";
      }
    }
    When I call this code and use the below pointcut the associated advice is run.

    Code:
    @Pointcut("execution(* com.abc.services..getValue())")
    However, when I try the below it is not run:
    Code:
    @Pointcut("execution(* com.abc.services.MyService.getValue())")
    Nor is it run with the following:
    Code:
    @Pointcut("execution(* com.abc.services.MyServiceImpl.getValue())")
    My Spring Config is as follows:

    Code:
    <aop:aspectj-autoproxy/>
    The interceptor class is declared in the same config as the <aop:..> tag but the services are in a sepreate config loaded via a <param-name>contextConfigLocation</param-name> entry in the web.xml

    Any help much appreciated.

    YP

  • #2
    Compiling a simple aspect from the command line according to your pointcuts, they match as expected. The difference I can see between the 3 is that the first is a pattern whereas the others are explicit about which type they mean.

    Does this pointcut work for you? (with an asterisk in the type name?)

    @Pointcut("execution(* com.abc.services.MyServ*ce.getValue())")

    Do you get any warnings out when explicitly mentioning the types about 'invalid absolute type name'?

    Andy.

    Comment

    Working...
    X