I've concluded that writing a custom logging interceptor requires
writing it from scratch, as opposed to trying to use the
Logging{Out,In}Interceptor as a base class or assuming it was executed
previously in the chain. I've tried both of those approaches, and they
reach dead ends.
So, I'm starting with the Logging{Out,In}Interceptor and trying to write
a single abstract class such that the subclass can be created as either
a IN or OUT interceptor.
I'm examining the two classes, LoggingOutInterceptor and
LoggingInInterceptor. I notice that they are similar, but different.
They are different specifically in the "handleMessage()" method. The
"Out" one uses CacheAndWriteOutputStream and registers a callback object
to handle the result. The "In" one just reads from the InputStream into
a CachedOutputStream. After that point, they both work similarly, as
they both have a CachedOutputStream and read from that into a
StringBuilder.
The "Out" interceptor is set in the PRE_STREAM phase, and the "In" is in
the RECEIVE phase. In that context, I guess I can understand why the
"Out" interceptor sets up a callback, but the "In" interceptor just
reads the content. Why exactly is the "Out" interceptor using
PRE_STREAM, as opposed to a later phase after the data has been
streamed? Is this done because the data is unavailable at that point?