You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cl...@apache.org on 2009/12/30 13:45:48 UTC

svn commit: r894605 - in /cxf/branches/2.2.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/interceptor/

Author: cleclerc
Date: Wed Dec 30 12:45:47 2009
New Revision: 894605

URL: http://svn.apache.org/viewvc?rev=894605&view=rev
Log:
Merged revisions 894603 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r894603 | cleclerc | 2009-12-30 13:41:21 +0100 (Wed, 30 Dec 2009) | 7 lines
  
  [CXF-2597] Add response code to LoggingFeature for REST/JAX-RS specific response codes
  LoggingMessage :
   add responseCode field
   output responseCode field in toString() method only if it is not empty (ie server side outbound message or client side inbound message)
   output payload field in toString() method only if it is not empty because it is common in REST to have empty payloads
  LoggingInInterceptor and LoggingOutInterceptor : fill LoggingMessage.responseCode field if the response code is found on the message
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java
    cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 30 12:45:47 2009
@@ -1 +1 @@
-/cxf/trunk:817055,891375-891393,891452,891817,891827,891859,891945-891946,892056,892307,892360,892664,892890,892920,892953,892988,893011,893250,893388-893389,893563,893773,894197
+/cxf/trunk:817055,891375-891393,891452,891817,891827,891859,891945-891946,892056,892307,892360,892664,892890,892920,892953,892988,893011,893250,893388-893389,893563,893773,894197,894603

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=894605&r1=894604&r2=894605&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Wed Dec 30 12:45:47 2009
@@ -108,7 +108,11 @@
         final LoggingMessage buffer 
             = new LoggingMessage("Inbound Message\n----------------------------", id);
 
-        
+        Integer responseCode = (Integer)message.get(Message.RESPONSE_CODE);
+        if (responseCode != null) {
+            buffer.getResponseCode().append(responseCode);
+        }
+
         String encoding = (String)message.get(Message.ENCODING);
 
         if (encoding != null) {

Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java?rev=894605&r1=894604&r2=894605&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java Wed Dec 30 12:45:47 2009
@@ -31,6 +31,7 @@
     private final StringBuilder header;
     private final StringBuilder message;
     private final StringBuilder payload;
+    private final StringBuilder responseCode;
     private final String id;
     
 
@@ -44,6 +45,7 @@
         header = new StringBuilder();
         message = new StringBuilder();
         payload = new StringBuilder();
+        responseCode = new StringBuilder();
     }
     
     public static String nextId() {
@@ -75,6 +77,10 @@
         return payload;
     }
 
+    public StringBuilder getResponseCode() {
+        return responseCode;
+    }
+
     public String toString() {
         StringBuilder buffer = new StringBuilder();
         buffer.append(heading);
@@ -83,8 +89,14 @@
             buffer.append("\nAddress: ");
             buffer.append(address);
         }
-        buffer.append("\nEncoding: ");
-        buffer.append(encoding);
+        if (responseCode.length() > 0) {
+            buffer.append("\nResponse-Code: ");
+            buffer.append(responseCode);
+        }
+        if (encoding.length() > 0) {
+            buffer.append("\nEncoding: ");
+            buffer.append(encoding);
+        }
         buffer.append("\nContent-Type: ");
         buffer.append(contentType);
         buffer.append("\nHeaders: ");
@@ -93,8 +105,10 @@
             buffer.append("\nMessages: ");
             buffer.append(message);
         }
-        buffer.append("\nPayload: ");
-        buffer.append(payload);
+        if (payload.length() > 0) {
+            buffer.append("\nPayload: ");
+            buffer.append(payload);
+        }
         buffer.append("\n--------------------------------------");
         return buffer.toString();
     }

Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java?rev=894605&r1=894604&r2=894605&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java Wed Dec 30 12:45:47 2009
@@ -117,6 +117,11 @@
                 = new LoggingMessage("Outbound Message\n---------------------------",
                                      id);
             
+            Integer responseCode = (Integer)message.get(Message.RESPONSE_CODE);
+            if (responseCode != null) {
+                buffer.getResponseCode().append(responseCode);
+            }
+            
             String encoding = (String)message.get(Message.ENCODING);
 
             if (encoding != null) {