Results 1 to 2 of 2

Thread: Skipping the invocation of the method being intercepted

  1. #1
    Join Date
    Aug 2004
    Location
    Singapore
    Posts
    3

    Default 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. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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).
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. PerformanceMonitorInterceptor
    By tnist in forum AOP
    Replies: 3
    Last Post: Aug 24th, 2005, 01:39 PM
  5. Replies: 8
    Last Post: Dec 7th, 2004, 06:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •