1

I am refactoring some code from Spring Integration 2.x to 4.x and have come across a compile error in a handler that extends AbstractReplyProducingMessageHandler.

The onInit method on that Abstract Class is final, yet my legacy code overrides it successfully in the 2.0 S.I. code.

There is a method that seems to be able to be over-ridden called

doInit()

What is the difference in use between the onInit method and the doInit method. The java docs are not very helpful (as a matter of fact they contain no information except the onInit method is final.)

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118

1 Answers1

1

Yes, you are right: there is no difference with those methods and they are just called from the IntegrationObjectSupport#afterPropertiesSet().

The reason to make onInit() as final to protect implementation from the issue not invoking the super.onInit() in their implementation :-).

As you see AbstractReplyProducingMessageHandler#onInit() has critical code like:

this.advisedRequestHandler = (RequestHandler) proxyFactory.getProxy(this.beanClassLoader);
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Please be sure to checkout the [migration guides](https://github.com/spring-projects/spring-integration/wiki). This particular breaking change was [documented here](https://github.com/spring-projects/spring-integration/wiki/Spring-Integration-2.2-to-3.0-Migration-Guide#abstractreplyproducingmessagehandler-oninit-method). – Gary Russell Mar 25 '15 at 14:41
  • Thank you both. I had read the 3.x to 4.x migration guide but had not read the 2.2 to 3.0 migration guide. – Stephen McConnell Mar 25 '15 at 23:51