Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Apache CXF中的LogginInterceptor_Java_Apache_Rest_Cxf_Interceptor - Fatal编程技术网

Java Apache CXF中的LogginInterceptor

Java Apache CXF中的LogginInterceptor,java,apache,rest,cxf,interceptor,Java,Apache,Rest,Cxf,Interceptor,我必须在拦截器级别编写一个CustomLogger,我指的是ApacheCXF中的LogginInterceptor代码。我在代码中看到,它首先从消息中获取输入流,然后将其设置回消息 请参阅以下代码和url以了解相同的内容: // restore the delegating input stream or the input stream if (is instanceof DelegatingInputStream) { ((DelegatingInputStrea

我必须在拦截器级别编写一个CustomLogger,我指的是ApacheCXF中的LogginInterceptor代码。我在代码中看到,它首先从消息中获取输入流,然后将其设置回消息

请参阅以下代码和url以了解相同的内容:

// restore the delegating input stream or the input stream 
   if (is instanceof DelegatingInputStream) { 
        ((DelegatingInputStream)is).setInputStream(bis); 
   } else { 
        **message.setContent(InputStream.class, bis);** 
   }


你能让我知道为什么这样做,即使我们不改变这里的输入流。如果对其进行详细描述,将非常有帮助。

输入流实际上已更改。日志记录将“消耗”其字节,然后流将被设置为结束。这使得它不能用于以下消息处理程序。因此,拦截器首先复制字节以将其保存在内存中,然后在新的输入流中使用它们,并在另一个新的输入流中为后续拦截器提供访问权限(这在实际http输入流中是不可能的,但在内存中的字节是可以的)