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?