• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring Aspect Question

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark, that was it.

 
reply
    Bookmark Topic Watch Topic
  • New Topic