I have a method with a return value in DAO layer, I want to change the return value by spring AOP, according different requirement,s and then send to corresponding method in SERVICE layer; but i don't know how to do so.
You can apply an @Around
aspect to the method whose return type should be modified. You can take a look at my blog post on how to add Spring AOP facet to a Spring application, then write an @Around
aspect. I used this aspect for Memoizing
results of a method, but in your case, you would take the return value of ProceedingJoinPoint.proceed()
, typecast it to appropriate class, then modify it and return it.
In case you plan to return a completely different object altogether, then that would result in ClassCastException, unless the actual returned object is a subclass of the return type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With