Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Usage of pointcut

Hi,

I have the following aspect:

public aspect DeprecatedMethodsAspect  {
       
    private  Collector collector = new DeprecatedMethodsListener();
   
    //Only allow a default constructor with no args.

    //Pointcuts to match joinpoint.
    pointcut deprecated() :
        !within(com.mylibrary.aspects.*) && @annotation(java.lang.Deprecated) && (call(public * *(..)) || call(*.new(..)));

    pointcut beta() :
        @annotation(com.google.common.annotations.Beta);

    pointcut deprecatedMethods() :
        deprecated() && !beta();
       

    before() : deprecatedMethods() {
        collector.collect(thisJoinPoint);
    }

}

I want to be able to select only packages in the application running with this aspect. So I want to have a default pointcut that is used by most users but with the possibility to override it.


I was thinking of defining abstract pointcuts ( then aspect needs to be abstract as well) like:


protected abstract pointcut excludedPackages();
protected abstract pointcut includedPackages();
Then I can define them in the aop.xml

But what is the best way to provide a default value/values ( if multiple packages).

br,

//mikael

 


Back to the top