Hi Dan,

This is my bad :(
I just used this function in the test, forgot about the interceptor will be mostly called multiple times.

What about register a callback method, and the interceptor call the callback method at the end of the handleMessage, and pass in the instance of LoggingMessage?
does it make sense?

Or we can put an Interceptor in the tests, and it's just for the tests purpose?

Regards,
James

Author: dkulp
Date: Mon Nov 12 13:24:56 2007
New Revision: 594302

URL: http://svn.apache.org/viewvc?rev=594302&view=rev
Log:
Fix logging interceptors to not store EVERYTHING logged to them and also be 
thread safe.

Modified:
    
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java

Modified: 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=594302&r1=594301&r2=594302&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
 (original)
+++ 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
 Mon Nov 12 13:24:56 2007
@@ -37,7 +37,6 @@
 public class LoggingInInterceptor extends AbstractPhaseInterceptor<Message> {
private static final Logger LOG = LogUtils.getL7dLogger(LoggingInInterceptor.class);
-    private final LoggingMessage buffer = new LoggingMessage("Inbound 
Message\n----------------------------");
private int limit = 100 * 1024;
     private boolean enabled;
@@ -56,10 +55,6 @@
         this.enabled = b;
     }
- public LoggingMessage getBuffer() {
-        return this.buffer;
-    }
- public void setLimit(int lim) {
         limit = lim;
     }
@@ -75,6 +70,9 @@
     }
private void logging(Message message) throws Fault {
+        final LoggingMessage buffer = new LoggingMessage("Inbound 
Message\n----------------------------");
+
+ String encoding = (String)message.get(Message.ENCODING); if (encoding != null) {

Modified: 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java?rev=594302&r1=594301&r2=594302&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
 (original)
+++ 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
 Mon Nov 12 13:24:56 2007
@@ -37,7 +37,6 @@
 public class LoggingOutInterceptor extends AbstractPhaseInterceptor {
private static final Logger LOG = LogUtils.getL7dLogger(LoggingOutInterceptor.class); - private final LoggingMessage buffer = new LoggingMessage("Outbound Message\n---------------------------"); private int limit = 100 * 1024;
     private boolean enabled;
@@ -64,10 +63,6 @@
         return limit;
} - public LoggingMessage getBuffer() {
-        return this.buffer;
-    }
- public void handleMessage(Message message) throws Fault {
         final OutputStream os = message.getContent(OutputStream.class);
         if (os == null) {
@@ -89,6 +84,8 @@
         }
public void onClose(CachedOutputStream cos) {
+            final LoggingMessage buffer = new LoggingMessage("Outbound 
Message\n---------------------------");
+
             if (cos.getTempFile() == null) {
                 //buffer.append("Outbound Message:\n");
                 if (cos.size() > limit) {


Reply via email to