cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r469514 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java ws/rm/src/main/java/org/apache/cxf/ws/rm/ForkOutputStream.java ws/rm/src/main/java/org/apache/cxf/ws/rm/LoggingOutInterceptor.java
Date Tue, 31 Oct 2006 15:01:53 GMT
Author: andreasmyth
Date: Tue Oct 31 07:01:52 2006
New Revision: 469514

URL: http://svn.apache.org/viewvc?view=rev&rev=469514
Log:
Slightly modified and moved LoggingOutInterceptor to core.

Added:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
      - copied, changed from r469495, incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/LoggingOutInterceptor.java
Removed:
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ForkOutputStream.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/LoggingOutInterceptor.java

Copied: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
(from r469495, incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/LoggingOutInterceptor.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java?view=diff&rev=469514&p1=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/LoggingOutInterceptor.java&r1=469495&p2=incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java&r2=469514
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/LoggingOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
Tue Oct 31 07:01:52 2006
@@ -17,14 +17,16 @@
  * under the License.
  */
 
-package org.apache.cxf.ws.rm;
+package org.apache.cxf.interceptor;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Collections;
 import java.util.Set;
+import java.util.logging.Logger;
 
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -33,7 +35,8 @@
  * 
  */
 public class LoggingOutInterceptor extends AbstractPhaseInterceptor {
-    
+   
+    private static final Logger LOG = LogUtils.getL7dLogger(LoggingOutInterceptor.class);

     private Set<String> before = Collections.singleton(StaxOutInterceptor.class.getName());
 
     public LoggingOutInterceptor() {
@@ -46,7 +49,7 @@
             return;
         }
 
-        ForkOutputStream fos = new ForkOutputStream(os, System.out);        
+        ForkOutputStream fos = new ForkOutputStream(os);
         message.setContent(OutputStream.class, fos);
     }
 
@@ -54,8 +57,51 @@
     public Set<String> getBefore() {
         return before;
     }
+
+    /**
+      * Output stream that multicasts its data to several underlying output streams.
+     */
+    public class ForkOutputStream extends OutputStream {
+
+        final OutputStream original;
+        final ByteArrayOutputStream bos;
+    
+        public ForkOutputStream(OutputStream o) {
+            original = o;
+            bos = new ByteArrayOutputStream();
+        }
+    
+        @Override
+        public void close() throws IOException {
+            bos.close();
+            LOG.info("Message: " + bos.toString());
+            original.close();
+        }
+
+        @Override
+        public void flush() throws IOException {
+            bos.flush();
+            original.flush();
+        }
+
+        @Override
+        public void write(byte[] b, int off, int len) throws IOException {
+            bos.write(b, off, len);
+            original.write(b, off, len);
+        }
     
+        @Override
+        public void write(byte[] b) throws IOException {
+            bos.write(b);
+            original.write(b);
+        }
     
+        @Override
+        public void write(int b) throws IOException {
+            bos.write(b);
+            original.write(b);
+        }
+    }
     
     
 }



Mime
View raw message