cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clecl...@apache.org
Subject svn commit: r894603 - in /cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor: LoggingInInterceptor.java LoggingMessage.java LoggingOutInterceptor.java
Date Wed, 30 Dec 2009 12:41:21 GMT
Author: cleclerc
Date: Wed Dec 30 12:41:21 2009
New Revision: 894603

URL: http://svn.apache.org/viewvc?rev=894603&view=rev
Log:
[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/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=894603&r1=894602&r2=894603&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Wed
Dec 30 12:41:21 2009
@@ -72,7 +72,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/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java?rev=894603&r1=894602&r2=894603&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java Wed Dec
30 12:41:21 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/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java?rev=894603&r1=894602&r2=894603&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
Wed Dec 30 12:41:21 2009
@@ -89,6 +89,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) {



Mime
View raw message