Results 1 to 4 of 4

Thread: ThrowsAdvice on synchronized method?

  1. #1
    Join Date
    Aug 2004
    Posts
    230

    Default ThrowsAdvice on synchronized method?

    What are the semantics of a ThrowsAdvice for a synchronized method? Do I need to synchronize the advice methods? Is that enough -- ie, Is the glue that spring uses to wrap the advised method synchronized? I guess this question applies to any aopalliance intercepter, no?
    Barry Kaplan (memelet)

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Spring does not synchronize in the AOP framework. Your target's synchronization will be unaffected if it uses synchronization--Spring is not changing its bytecodes. Does this answer your question?
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Posts
    230

    Default

    Quote Originally Posted by Rod Johnson
    ....Does this answer your question?
    Not really. I asking more about MethodInterceptor and the advise that it calls prior to the advised method.

    What I believe is: Since MethodInterceptor will invoke the advice prior the synced method they wrap, the advice is not part of the synchronized block.

    After thinking more on this, it seems obvious. Spring advice is allways aspectj calls-style, which also would have the same issue. Aspectj execution-style would (I think) be included inside the synhronized block. I just wanted to be clear what the requirements of advisor methods when they advise syncrhronized methods.

    (Am I making any sense?)
    Barry Kaplan (memelet)

  4. #4
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Barry

    What I believe is: Since MethodInterceptor will invoke the advice prior the synced method they wrap, the advice is not part of the synchronized block.
    That is correct. If you want to synchronize the advice on the target instance you could synchronize on MethodInvocation.getThis.

    Or you could address the threadsafety issue with a pooling TargetSource.

    Rgds
    Rod
    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: 1
    Last Post: Jul 28th, 2005, 05:08 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
  •