aspose file tools*
The moose likes Spring and the fly likes Spring Aspect Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Aspect Question" Watch "Spring Aspect Question" New topic
Author

Spring Aspect Question

Jeremy Odell
Greenhorn

Joined: Mar 30, 2011
Posts: 4
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

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Jeremy Odell
Greenhorn

Joined: Mar 30, 2011
Posts: 4
Thanks Mark, that was it.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring Aspect Question