문제

I am doing Spring Aspect Oriented Programming with annotations in Java. I have an Aspect LogAOP:

@Aspect
public class LogAOP {

  @DeclareParents(value="beans.service.*+",     //Line 1
                  defaultImpl= EventImpl.class)
  public static Event mixin;

  @Before("com.beans.business.businessService() &&" +
          "this(abc)")
  public void usage(Event abc) {
    abc.increment();
  }

}

I am not able to understand the significance of '+' symbol in Line 1 in value attribute of @DeclareParents annotation. Beacuse even if I remove this + symbol, the program is running fine. I have also searched in official documentation of Spring AOP (http://docs.spring.io/spring/docs/2.5.4/reference/aop.html) , nothing is mentioned there.

도움이 되었습니까?

해결책

Using + after a class name or interface name is used to match that class or interface, and all it's subclasses. So, the pointcut expression in this case:

@DeclareParents(value="beans.service.*+",     //Line 1
              defaultImpl= EventImpl.class)
public static Event mixin;

...will match any interfaces or class defined in package beans.service, and also any subclass or implementing class of those classes and interfaces. It may be needed because, the implementing classes might not be in the beans.service package. In your case, you're not seeing the effect because may be all your implementing classes are in the same package. Try implementing an interface in beans.service package, and put the implementing class in a different package. I guess, you'll see the difference then.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top