You're thinking along the right lines, it just needs fleshing out with specifics. Brace yourself, I'm going to hit you with a bunch of long class names...
The client-side factory that generates the stub that talks to the remote service is HttpInvokerProxyFactoryBean
. The superclass (HttpInvokerClientInterceptor
) has a property called httpInvokerRequestExecutor
, which defaults to an instance of SimpleHttpInvokerRequestExecutor
.
This is ripe for subclassing and extending; specifically it has a decorateInputStream
method which you can use:
public class CountingHttpInvokerRequestExecutor extends SimpleHttpInvokerRequestExecutor {
@Override
protected InputStream decorateInputStream(InputStream is) throws IOException {
return new CountingInputStream(super.decorateInputStream(is));
}
}
And then inject that into the proxy factory:
<bean class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="httpInvokerRequestExecutor">
<bean class="com.mycompany.CountingHttpInvokerRequestExecutor"/>
</property>
<!-- Plus the various other properties required by HttpInvokerProxyFactoryBean -->
<!-- URL, proxy interface, etc -->
</bean>
The trick then becomes to get hold of that information, which will require some creative rewiring. You could, for example, obtain the new instances of CountingInputStream
from another factory somewhere, which would then expose the byte count to your user interface.