Announcement Announcement Module
Collapse
No announcement yet.
Skipping the invocation of the method being intercepted Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Skipping the invocation of the method being intercepted

    Hi,

    I am using AOP to implement a caching mechanism. I have an adivsor that extends org.aopalliance.intercept.MethodInterceptor and do some checking. If the cache is up to date, I will return the cached copy and methodInvocation.proceed() will NOT be called. If the cache is outdated, methodInvocation.proceed() will be called and after the calling, the result will be cached.

    However, by skipping methodInvocation.proceed(), the adivsors that appear after my advisor in the adivsorchain will not be invoked, either. This sounds like my advisor is not very well behaved.

    Any suggestion? Is there any way in Spring AOP to signal that the final method invocation to be skipped while keeping the chain running till the end. (I can immediately see a conflict if one adivsor says skip and another says not to skip)

    Or am I misusing AOP?


    Thanks

    Zehua

  • #2
    Can you put your caching interceptor last in the interceptor chain so that all other advice will always be executed first?

    Otherwise, you could use a ThreadLocal flag. There's no built-in mechanism to flag the invocation not to proceed (it would need to carry the return value also).

    Comment

    Working...
    X