Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Aspect Question

 
Jeremy Odell
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in the process of using the @AfterReturning advice. I have set this up to be used for an annotation I have created. The advice looks like:


Now I have set up my Annotation to have certain parameters set. I would like to use these in the above advice.

How do I pass in the annotation?


Thanks,
Jeremy
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeremy.

Using the @Annotation designator or, if it is an argument that is annotated, then the @Args, or if it is the target that is Annotated then @Target.

In your case it would be @Annotation, so in your Pointcut Expression you add the @Annotation designator with an "and" or "&&"

so

execution(@com.rbs.etspii.aspects.CheckAssetType com.rbs.base.common.RBSValidationResult submit*(..)) && @Annotation(assetType)"

Now in your advice method you can have the parameter
myAdviceMethod(ResultType result, CheckAssetType assetType)

Like this taken from the SpringFramework documentation

And then the advice that matches the execution of @Auditable methods:





Mark
 
Jeremy Odell
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark, that was it.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic