Results 1 to 3 of 3

Thread: Change target of MethodInvocation in MethodInterceptor?

  1. #1
    Join Date
    Apr 2005
    Posts
    2

    Default Change target of MethodInvocation in MethodInterceptor?

    Hi,

    I am trying to build some sort of retry and micro-reboot functionality as aspects, pluggable in spring. I am using a ProxyFactoryBean with a MethodInterceptor. The MethodInterceptor is able to do retries on the target, if the target fails with a RecoverableException. That works as desired.

    Then I want my MethodInterceptor to be able to "reboot" components, if they fail with a not recoverable Exception. The MethodInterceptor uses a subclassed HotSwappableTargetSource that is able to swap to a new instance if the old one fails. It works as desired, but ...

    The MethodInterceptor notes the failure of a component and reboots it (creates a new one and swaps to it) but the MethodInvocation can't be invoked, as it uses the old target. My workaround is to modify the ReflectiveMethodInvocation so that it provides a clone with a new target.

    Is there another solution? I am new to Spring, so maybe I missed something obvious?

    Regards,
    Alex

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

    Default

    The target will have been allocated at that point and associated with the invocation. So your solution is probably the only approach.

    I guess we could add a setTarget() method to ReflectiveMethodInvocation. Although that does subvert the TargetSource mechanism, so I'm not sure it would be prudent.

    Anyone else need this?
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Apr 2005
    Posts
    2

    Default

    Hi Rod,

    maybe it's possible to provide a method that clones the ReflectiveMethodInvocation with a new target. That is a bit less subverting as a setTarget().

    Regards, Alex

Similar Threads

  1. Replies: 9
    Last Post: Oct 14th, 2005, 09:38 AM
  2. Change Password interim step
    By markstgodard in forum Security
    Replies: 5
    Last Post: Jul 19th, 2005, 02:59 AM
  3. Replies: 1
    Last Post: Feb 17th, 2005, 04:39 AM
  4. Replies: 1
    Last Post: Jan 15th, 2005, 04:50 PM
  5. Replies: 2
    Last Post: Sep 3rd, 2004, 10:42 AM

Posting Permissions

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