android android-annotations rest spring spring-mvc

Handling timeout with AndroidAnnotations (Spring Rest)

Basically, what I’m facing today is the following:

  • Handle Request time out when doing Rest actions.

Seems simple written, but not as easy to code.

This is my implementation so far:

List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
interceptors.add( new NetworkInterceptor() );
tpl.setInterceptors( interceptors );

So now, after setting interceptors, I’d like to set custom timeout configurations for the template.

So I do the following:

This is returning a InterceptingClientHttpRequestFactory instead of SimpleClientHttpRequestFactory as would be returned in case no interceptors were set.

So as it is returning that InterceptingClientHttpRequestFactory instance, I can’t set the Timeout.

You can check the sourcecode of Spring, the last method:

So… Any tips?