Author: ningjiang
Date: Thu Aug 23 12:57:12 2012
New Revision: 1376474

URL: http://svn.apache.org/viewvc?rev=1376474&view=rev
Log:
CAMEL-5538 Added skipFaultLogging option to disable the Fault logging in 
PhaseInterceptorChain

Added:
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/NullFaultListener.java
Modified:
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientBlueprintBean.java
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSClientFactoryBean.java
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSServerFactoryBean.java
    camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd
    
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointsRouterContext.xml
    
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
 Thu Aug 23 12:57:12 2012
@@ -82,6 +82,7 @@ import org.apache.cxf.jaxws.context.WebS
 import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.logging.FaultListener;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
@@ -133,6 +134,7 @@ public class CxfEndpoint extends Default
     private String address;
     private boolean mtomEnabled;
     private boolean skipPayloadMessagePartCheck;
+    private boolean skipFaultLogging;
     private Map<String, Object> properties;
     private List<Interceptor<? extends Message>> in 
         = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
@@ -311,6 +313,13 @@ public class CxfEndpoint extends Default
             }
             sfb.getProperties().put("soap.no.validate.parts", Boolean.TRUE);
         }
+        
+        if (this.isSkipFaultLogging()) {
+            if (sfb.getProperties() == null) {
+                sfb.setProperties(new HashMap<String, Object>());              
  
+            }
+            sfb.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
 
         sfb.setBus(getBus());
         sfb.setStart(false);
@@ -476,6 +485,13 @@ public class CxfEndpoint extends Default
             }
             factoryBean.getProperties().put("soap.no.validate.parts", 
Boolean.TRUE);
         }
+        
+        if (this.isSkipFaultLogging()) {
+            if (factoryBean.getProperties() == null) {
+                factoryBean.setProperties(new HashMap<String, Object>());      
          
+            }
+            factoryBean.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
 
         factoryBean.setBus(getBus());
     }
@@ -1032,6 +1048,14 @@ public class CxfEndpoint extends Default
         return bindingConfig;
     }
 
+    public boolean isSkipFaultLogging() {
+        return skipFaultLogging;
+    }
+
+    public void setSkipFaultLogging(boolean skipFaultLogging) {
+        this.skipFaultLogging = skipFaultLogging;
+    }
+
     public void setBindingConfig(BindingConfiguration bindingConfig) {
         this.bindingConfig = bindingConfig;
     }

Added: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/NullFaultListener.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/NullFaultListener.java?rev=1376474&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/NullFaultListener.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/NullFaultListener.java
 Thu Aug 23 12:57:12 2012
@@ -0,0 +1,30 @@
+/**
+ * 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.camel.component.cxf;
+
+import org.apache.cxf.logging.FaultListener;
+import org.apache.cxf.message.Message;
+
+public class NullFaultListener implements FaultListener {
+
+    @Override
+    public boolean faultOccurred(Exception exception, String description, 
Message message) {
+        // will disable the default logging 
+        return false;
+    }
+
+}

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientBlueprintBean.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientBlueprintBean.java?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientBlueprintBean.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsClientBlueprintBean.java
 Thu Aug 23 12:57:12 2012
@@ -16,8 +16,12 @@
  */
 package org.apache.camel.component.cxf.blueprint;
 
+import java.util.HashMap;
+
+import org.apache.camel.component.cxf.NullFaultListener;
 import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.logging.FaultListener;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 
@@ -79,5 +83,14 @@ public class RsClientBlueprintBean exten
             getFeatures().add(loggingFeature);
         }
     }
+    
+    public void setSkipFaultLogging(boolean skipFaultLogging) {
+        if (skipFaultLogging) {
+            if (this.getProperties() == null) {
+                this.setProperties(new HashMap<String, Object>());
+            }
+            this.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
+    }
 
 }

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java
 Thu Aug 23 12:57:12 2012
@@ -16,8 +16,12 @@
  */
 package org.apache.camel.component.cxf.blueprint;
 
+import java.util.HashMap;
+
+import org.apache.camel.component.cxf.NullFaultListener;
 import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.logging.FaultListener;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 
@@ -81,4 +85,13 @@ public class RsServerBlueprintBean exten
         }
     }
     
+    public void setSkipFaultLogging(boolean skipFaultLogging) {
+        if (skipFaultLogging) {
+            if (this.getProperties() == null) {
+                this.setProperties(new HashMap<String, Object>());
+            }
+            this.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
+    }
+    
 }

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
 Thu Aug 23 12:57:12 2012
@@ -68,6 +68,8 @@ public class CxfRsComponent extends Head
                 copy.putAll(bean.getProperties());     
                 setProperties(answer, copy);      
             }
+            // setup the skipFaultLogging
+           
             
         } else {
             // endpoint URI does not specify a bean

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
 Thu Aug 23 12:57:12 2012
@@ -18,6 +18,7 @@ package org.apache.camel.component.cxf.j
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -29,6 +30,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.Service;
 import org.apache.camel.component.cxf.CxfEndpointUtils;
+import org.apache.camel.component.cxf.NullFaultListener;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
@@ -38,6 +40,7 @@ import org.apache.cxf.BusFactory;
 import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.logging.FaultListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,6 +59,7 @@ public class CxfRsEndpoint extends Defau
     private int maxClientCacheSize = 10;
     private boolean loggingFeatureEnabled;
     private int loggingSizeLimit;
+    private boolean skipFaultLogging;
     
     private AtomicBoolean getBusHasBeenCalled = new AtomicBoolean(false);
 
@@ -126,6 +130,14 @@ public class CxfRsEndpoint extends Defau
         return binding;
     }
     
+    public boolean isSkipFaultLogging() {
+        return skipFaultLogging;
+    }
+
+    public void setSkipFaultLogging(boolean skipFaultLogging) {
+        this.skipFaultLogging = skipFaultLogging;
+    }
+    
     protected void checkBeanType(Object object, Class<?> clazz) {
         if (!clazz.isAssignableFrom(object.getClass())) {
             throw new IllegalArgumentException("The configure bean is not the 
instance of " + clazz.getName());
@@ -164,6 +176,12 @@ public class CxfRsEndpoint extends Defau
                 cfb.getFeatures().add(new LoggingFeature());
             }
         }
+        if (this.isSkipFaultLogging()) {
+            if (cfb.getProperties() == null) {
+                cfb.setProperties(new HashMap<String, Object>());
+            }
+            cfb.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
         cfb.setThreadSafe(true);
     }
     
@@ -198,6 +216,12 @@ public class CxfRsEndpoint extends Defau
                 answer.getFeatures().add(new LoggingFeature());
             }
         }
+        if (this.isSkipFaultLogging()) {
+            if (answer.getProperties() == null) {
+                answer.setProperties(new HashMap<String, Object>());
+            }
+            answer.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
         return answer;
     }
     
@@ -216,6 +240,12 @@ public class CxfRsEndpoint extends Defau
                 answer.getFeatures().add(new LoggingFeature());
             }
         }
+        if (this.isSkipFaultLogging()) {
+            if (answer.getProperties() == null) {
+                answer.setProperties(new HashMap<String, Object>());
+            }
+            answer.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
         return answer;
     }
 

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSClientFactoryBean.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSClientFactoryBean.java?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSClientFactoryBean.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSClientFactoryBean.java
 Thu Aug 23 12:57:12 2012
@@ -16,14 +16,17 @@
  */
 package org.apache.camel.component.cxf.spring;
 
+import java.util.HashMap;
 import java.util.List;
 
+import org.apache.camel.component.cxf.NullFaultListener;
 import org.apache.camel.component.cxf.jaxrs.BeanIdAware;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.logging.FaultListener;
 import org.apache.cxf.version.Version;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
@@ -101,8 +104,17 @@ public class SpringJAXRSClientFactoryBea
         beanId = id;            
     }
     
-    // add this mothod for testing
+    // add this method for testing
     List<String> getSchemaLocations() {
         return schemaLocations;
     }
+   
+    public void setSkipFaultLogging(boolean skipFaultLogging) {
+        if (skipFaultLogging) {
+            if (this.getProperties() == null) {
+                this.setProperties(new HashMap<String, Object>());
+            }
+            this.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
+    }
 }
\ No newline at end of file

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSServerFactoryBean.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSServerFactoryBean.java?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSServerFactoryBean.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/SpringJAXRSServerFactoryBean.java
 Thu Aug 23 12:57:12 2012
@@ -16,8 +16,10 @@
  */
 package org.apache.camel.component.cxf.spring;
 
+import java.util.HashMap;
 import java.util.List;
 
+import org.apache.camel.component.cxf.NullFaultListener;
 import org.apache.camel.component.cxf.jaxrs.BeanIdAware;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
@@ -25,6 +27,7 @@ import org.apache.cxf.bus.spring.SpringB
 import org.apache.cxf.feature.LoggingFeature;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
+import org.apache.cxf.logging.FaultListener;
 import org.apache.cxf.version.Version;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
@@ -106,5 +109,14 @@ public class SpringJAXRSServerFactoryBea
             }
             getFeatures().add(loggingFeature);
         }
-    }   
+    }
+
+    public void setSkipFaultLogging(boolean skipFaultLogging) {
+        if (skipFaultLogging) {
+            if (this.getProperties() == null) {
+                this.setProperties(new HashMap<String, Object>());
+            }
+            this.getProperties().put(FaultListener.class.getName(), new 
NullFaultListener());
+        }
+    }
 }
\ No newline at end of file

Modified: 
camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd 
(original)
+++ camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd 
Thu Aug 23 12:57:12 2012
@@ -57,6 +57,7 @@
           <xsd:attribute name="serviceName" type="xsd:string" />
           <xsd:attribute name="loggingFeatureEnabled" type="xsd:boolean"/>
           <xsd:attribute name="loggingSizeLimit" type="xsd:integer" />
+          <xsd:attribute name="skipFaultLogging" type="xsd:boolean" />
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>
@@ -94,6 +95,7 @@
           <xsd:attribute name="staticSubresourceResolution" type="xsd:boolean" 
/>
           <xsd:attribute name="loggingFeatureEnabled" type="xsd:boolean"/>
           <xsd:attribute name="loggingSizeLimit" type="xsd:integer" />
+          <xsd:attribute name="skipFaultLogging" type="xsd:boolean" />
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>
@@ -130,6 +132,7 @@
           <xsd:attribute name="password" type="xsd:string"/>
           <xsd:attribute name="loggingFeatureEnabled" type="xsd:boolean"/>
           <xsd:attribute name="loggingSizeLimit" type="xsd:integer" />
+          <xsd:attribute name="skipFaultLogging" type="xsd:boolean" />
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>

Modified: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointsRouterContext.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointsRouterContext.xml?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointsRouterContext.xml
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointsRouterContext.xml
 Thu Aug 23 12:57:12 2012
@@ -31,7 +31,8 @@
 
    <!-- START SNIPPET: example -->
    <cxf:cxfEndpoint id="routerEndpoint" 
address="http://localhost:${CXFTestSupport.port2}/CXFGreeterRouterTest/CamelContext/RouterPort";
-               serviceClass="org.apache.hello_world_soap_http.GreeterImpl">
+               serviceClass="org.apache.hello_world_soap_http.GreeterImpl"
+               skipFaultLogging="true">
         <cxf:outInterceptors>
             <!-- This interceptor will force the CXF server send the XML start 
document to client -->
             <bean 
class="org.apache.camel.component.cxf.WriteXmlDeclarationInterceptor"/>

Modified: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml?rev=1376474&r1=1376473&r2=1376474&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml
 Thu Aug 23 12:57:12 2012
@@ -45,12 +45,12 @@
   <!-- Defined the server endpoint to create the cxf-rs consumer --> 
   <cxf:rsServer id="rsServer" 
address="http://localhost:${CXFTestSupport.port1}/CxfRsRouterTest/route";
     
serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService" 
-    loggingFeatureEnabled="true" loggingSizeLimit="20"/>
+    loggingFeatureEnabled="true" loggingSizeLimit="20" 
skipFaultLogging="true"/>
 
   <!-- Defined the client endpoint to create the cxf-rs consumer -->
   <cxf:rsClient id="rsClient" 
address="http://localhost:${CXFTestSupport.port2}/CxfRsRouterTest/rest";
     
serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"
-    loggingFeatureEnabled="true" />
+    loggingFeatureEnabled="true" skipFaultLogging="true"/>
   
   <!-- The camel route context -->
   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring";>


Reply via email to