I have an Aspect that defines @Around advice.

@Aspect
class FooAspect {
  @spring.Autowired Env env;

  @Around(some())
  public Object advice(String name) {
     return env.get(name);
  }
}

I'd like this Aspect to execute when env is not null and delegate to
JoinPoint when it is null.

@Around(some())
public Object advice(String name, ProceedingJointPoint pjp) {
   if (env != null) {
        return env.get(name);
    else
        return pjp.proceed();
}

However, I'd like to avoid cluttering the advice and do something like this
instead.

@Pointcut("if()")
public static boolean isActive(FooAspect aspect) {
   return aspect.env != null;
}

 @Around(isActive() && some())
  public Object advice(String name, ProceedingJointPoint pjp) {
     return env.get(name);
  }

Question: is there a way to pass the instance of the advice to the
isActive() pointcut?

I'd like to avoid using Aspects.aspectOf() to get hold of the instance.

Thanks,
Alex
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to