cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r911058 - in /cxf/trunk/rt/management/src/main/java/org/apache/cxf/management: interceptor/PersistOutInterceptor.java persistence/ExchangeDataFilter.java persistence/FilesystemExchangeDataDAO.java persistence/StatusExchangeDataFilter.java
Date Wed, 17 Feb 2010 16:32:30 GMT
Author: sergeyb
Date: Wed Feb 17 16:32:29 2010
New Revision: 911058

URL: http://svn.apache.org/viewvc?rev=911058&view=rev
Log:
CXF-2670: applying the patch on behalf of RĂ©mi Flament, thanks 

Added:
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/ExchangeDataFilter.java
  (with props)
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/StatusExchangeDataFilter.java
  (with props)
Modified:
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/PersistOutInterceptor.java
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/PersistOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/PersistOutInterceptor.java?rev=911058&r1=911057&r2=911058&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/PersistOutInterceptor.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/PersistOutInterceptor.java
Wed Feb 17 16:32:29 2010
@@ -33,6 +33,7 @@
 import org.apache.cxf.io.CachedOutputStreamCallback;
 import org.apache.cxf.management.persistence.ExchangeData;
 import org.apache.cxf.management.persistence.ExchangeDataDAO;
+import org.apache.cxf.management.persistence.ExchangeDataFilter;
 import org.apache.cxf.management.persistence.ExchangeDataProperty;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -42,11 +43,13 @@
 
 public class PersistOutInterceptor extends AbstractPhaseInterceptor<Message> {
 
-    public static final String CXF_CONSOLE_ADDITIONAL_PROPERTY_PREFIX = 
+    public static final String CXF_CONSOLE_ADDITIONAL_PROPERTY_PREFIX =
         "org.apache.cxf.management.interceptor.prefix";
 
     private ExchangeDataDAO exchangeDataDAO;
 
+    private ExchangeDataFilter exchangeDataFilter;
+
     public PersistOutInterceptor() {
         super(Phase.PRE_STREAM);
     }
@@ -57,7 +60,7 @@
         private final OutputStream origStream;
         private final ExchangeData exchange;
 
-        public PersistOutInterceptorCallback(final Message msg, final OutputStream os, 
+        public PersistOutInterceptorCallback(final Message msg, final OutputStream os,
                                              final ExchangeData ex) {
             this.message = msg;
             this.origStream = os;
@@ -88,11 +91,14 @@
             }
             this.message.setContent(OutputStream.class, this.origStream);
 
-            try {
-                PersistOutInterceptor.this.exchangeDataDAO.save(this.exchange);
-            } catch (Throwable e) {
+            if (PersistOutInterceptor.this.exchangeDataFilter == null
+                || PersistOutInterceptor.this.exchangeDataFilter.shouldPersist(this.exchange))
{
+                try {
+                    PersistOutInterceptor.this.exchangeDataDAO.save(this.exchange);
+                } catch (Throwable e) {
 
-                e.printStackTrace();
+                    e.printStackTrace();
+                }
             }
         }
 
@@ -133,14 +139,14 @@
                 }
 
             } else if (entry.getKey().startsWith("org.apache.cxf.message.Message.")
-                       && (entry.getValue() instanceof String || entry.getValue()
instanceof Integer || entry
-                           .getValue() instanceof Boolean)) {
+                && (entry.getValue() instanceof String || entry.getValue() instanceof
Integer || entry
+                    .getValue() instanceof Boolean)) {
                 addProperty(exchange, entry.getKey(), entry.getValue().toString());
 
             } else if (entry.getKey().startsWith(CXF_CONSOLE_ADDITIONAL_PROPERTY_PREFIX))
{
                 addProperty(exchange, entry.getKey().substring(
                                                                CXF_CONSOLE_ADDITIONAL_PROPERTY_PREFIX
-                                                                   .length()), entry.getValue().toString());
+                                                               .length()), entry.getValue().toString());
 
             }
         }
@@ -217,4 +223,8 @@
         this.exchangeDataDAO = exchangeDataDAO;
     }
 
+    public void setExchangeDataFilter(ExchangeDataFilter exchangeDataFilter) {
+        this.exchangeDataFilter = exchangeDataFilter;
+    }
+
 }

Added: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/ExchangeDataFilter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/ExchangeDataFilter.java?rev=911058&view=auto
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/ExchangeDataFilter.java
(added)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/ExchangeDataFilter.java
Wed Feb 17 16:32:29 2010
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.management.persistence;
+
+/**
+ * This interface can be implemented to indicate to PersistOutInterceptor
+ * if an ExchangeData should be persisted.
+ * 
+ * @author remi
+ *
+ */
+public interface ExchangeDataFilter {
+
+    boolean shouldPersist(ExchangeData data);
+
+}

Propchange: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/ExchangeDataFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/ExchangeDataFilter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java?rev=911058&r1=911057&r2=911058&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
Wed Feb 17 16:32:29 2010
@@ -21,13 +21,18 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.StringWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
 
 public class FilesystemExchangeDataDAO implements ExchangeDataDAO {
 
+    private static final Logger LOG = LogUtils.getL7dLogger(FilesystemExchangeDataDAO.class);
+
     private String directory;
 
     private String extension = "txt";
-    
 
     public void setDirectory(String directory) {
         this.directory = directory;
@@ -36,10 +41,10 @@
     public void save(ExchangeData exchange) throws Exception {
         File file = null;
 
-        if (directory == null) {
-            file = File.createTempFile("cxf-management-", "." + extension);
+        if (this.directory == null) {
+            file = File.createTempFile("cxf-management-", "." + this.extension);
         } else {
-            file = File.createTempFile("cxf-management-", "." + extension, new File(directory));
+            file = File.createTempFile("cxf-management-", "." + this.extension, new File(this.directory));
         }
 
         StringWriter stringWriter = new StringWriter();
@@ -117,5 +122,9 @@
 
         fileOutputStream.close();
 
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Exchange data saved in " + file.getAbsolutePath());
+        }
+
     }
 }

Added: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/StatusExchangeDataFilter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/StatusExchangeDataFilter.java?rev=911058&view=auto
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/StatusExchangeDataFilter.java
(added)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/StatusExchangeDataFilter.java
Wed Feb 17 16:32:29 2010
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.management.persistence;
+
+/**
+ * This filter will only persist exchange data with a specific status.
+ * 
+ * @author remi
+ *
+ */
+public class StatusExchangeDataFilter implements ExchangeDataFilter {
+
+    private String statusFilter = "ERROR";
+
+    public void setStatusFilter(String statusFilter) {
+        this.statusFilter = statusFilter;
+    }
+
+    public boolean shouldPersist(ExchangeData data) {
+
+        return data != null && this.statusFilter.equals(data.getStatus());
+    }
+
+}

Propchange: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/StatusExchangeDataFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/StatusExchangeDataFilter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message