Djordje Ivanovic
Djordje Ivanovic

Reputation: 4259

Is it possible to parametrize Java Aspect

Is it possible to parametrize an Aspect? Right now I have an @Integration Aspect and my pointcuts are like:

@AfterReturning(pointcut = "@annotation(Integration)",returning = "result")

So, wherever it finds @Integration, it will call this method. Can I implement something like this:

@Integration("new") or @Integration("deleted"), 

to avoid to create new annotation for every case?

Also, if this is possible, how to access this provided value ("new" or "deleted").

Thanks in advance :)

Upvotes: 1

Views: 134

Answers (1)

Konstantin V. Salikhov
Konstantin V. Salikhov

Reputation: 4653

  1. Yes it's possible
  2. Here is description of how to add a value to your annotation
  3. Here is the article full of examples of annotation processing with AspectJ; e.g. Listing 8 shows how to access your annotation value inside of aspect

Upvotes: 1

Related Questions