cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jp...@apache.org
Subject cxf git commit: CXF-6118 various cleanups and refinements to the fallback logic to remain compatible with what's already in place
Date Thu, 27 Nov 2014 07:15:52 GMT
Repository: cxf
Updated Branches:
  refs/heads/cxf6118 6b5ec6eba -> d962278df


CXF-6118 various cleanups and refinements to the fallback logic to remain compatible with
what's already in place


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d962278d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d962278d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d962278d

Branch: refs/heads/cxf6118
Commit: d962278dfc4974027f17af2bae576ec2635cf90e
Parents: 6b5ec6e
Author: Jason Pell <jpell@apache.org>
Authored: Thu Nov 27 18:15:46 2014 +1100
Committer: Jason Pell <jpell@apache.org>
Committed: Thu Nov 27 18:15:46 2014 +1100

----------------------------------------------------------------------
 .../org/apache/cxf/helpers/ServiceUtils.java    | 23 ++++--------
 .../AbstractInDatabindingInterceptor.java       | 33 +----------------
 .../AbstractOutDatabindingInterceptor.java      | 39 ++------------------
 .../cxf/binding/soap/RPCOutInterceptorTest.java | 12 +++++-
 4 files changed, 24 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d962278d/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java b/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
index 0d10224..859b035 100644
--- a/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
+++ b/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
@@ -50,22 +50,11 @@ public final class ServiceUtils {
     }
     
     public static SchemaValidationType getSchemaValidationType(Message message) {
-        return getSchemaValidationType(message, SchemaValidationType.BOTH);
+        Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+        return getSchemaValidationType(obj);
     }
     
-    /**
-     * Determines the appropriate SchemaValidationType to return based on either
-     * a Boolean (for backwards compatibility) or the selected Schema Validation Type.
-     * 
-     * Package private as the isSchemaValidationEnabled method should be used instead.  Only
-     * visible for easier testing
-     * 
-     * @param message
-     */
-    public static SchemaValidationType getSchemaValidationType(Message message, SchemaValidationType
defaultType) {
-        // we do not want contextual property, as we just want to know what's 
-        // explicitly been set as a property in the message, most likely by a jaxws:endpoint
or jaxws:client properties
-        Object obj = message.get(Message.SCHEMA_VALIDATION_ENABLED);
+    public static SchemaValidationType getSchemaValidationType(Object obj) {
         if (obj instanceof SchemaValidationType) {
             return (SchemaValidationType)obj;
         } else if (obj != null) { 
@@ -79,9 +68,13 @@ public final class ServiceUtils {
             }
         }
         
-        return defaultType;
+        // fall through default value
+        return SchemaValidationType.NONE;
     }
     
+    /**
+     * For accessing the various *Info model objects, all of which extend AbstractPropertiesHolder
+     */
     public static SchemaValidationType getSchemaValidationType(AbstractPropertiesHolder properties)
{
         return (SchemaValidationType) properties.getProperty(Message.SCHEMA_VALIDATION_ENABLED);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/d962278d/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
b/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
index b93efef..959ef7f 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
@@ -38,7 +38,6 @@ import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.ServiceUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -51,7 +50,7 @@ import org.apache.cxf.service.model.ServiceModelUtil;
 import org.apache.cxf.staxutils.DepthXMLStreamReader;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 
-public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInterceptor<Message>
{
+public abstract class AbstractInDatabindingInterceptor extends AbstractDatabindingInterceptor
{
     public static final String NO_VALIDATE_PARTS = AbstractInDatabindingInterceptor.class.getName()

                                                     + ".novalidate-parts";
     private static final QName XSD_ANY = new QName("http://www.w3.org/2001/XMLSchema", "anyType",
"xsd");
@@ -67,10 +66,6 @@ public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInte
         super(i, phase);
     }
     
-    protected boolean isRequestor(Message message) {
-        return Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
-    }
- 
     protected boolean supportsDataReader(Message message, Class<?> input) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         Class<?> cls[] = service.getDataBinding().getSupportedReaderFormats();
@@ -126,32 +121,6 @@ public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInte
         }
     }
     
-    /**
-     * Where an operation level validation type has been set, copy it to the message, so
it can be interrogated
-     * by all downstream interceptors.  It is expected that sub classes will call setDataReaderValidation
subsequent
-     * to this to ensure the DataReader schema reference is updated as appropriate.
-     * 
-     * @param bop
-     * @param message
-     * @param reader
-     * @see #setDataReaderValidation(Service, Message, DataReader)
-     */
-    protected void setOperationSchemaValidation(EndpointInfo ep, OperationInfo opInfo, Message
message) {
-        SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message,
null);
-        if (validationType == null && opInfo != null) {
-            validationType = ServiceUtils.getSchemaValidationType(opInfo);
-            
-            // else fall back to endpoint level schema validation
-            if (validationType == null) {
-                validationType = ServiceUtils.getSchemaValidationType(ep);
-            }
-            
-            if (validationType != null) {
-                message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
-            }
-        }
-    }
-    
     protected DepthXMLStreamReader getXMLStreamReader(Message message) {
         XMLStreamReader xr = message.getContent(XMLStreamReader.class);
         if (xr == null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/d962278d/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
b/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
index 3dab1b8..b3fd50f 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
@@ -38,19 +38,16 @@ import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.message.MessageUtils;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.staxutils.CachingXmlEventWriter;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 
-public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInterceptor<Message>
{
-
+public abstract class AbstractOutDatabindingInterceptor extends AbstractDatabindingInterceptor
{
     public static final String DISABLE_OUTPUTSTREAM_OPTIMIZATION = "disable.outputstream.optimization";
     public static final String OUT_BUFFERING = "org.apache.cxf.output.buffering";
     
@@ -61,9 +58,6 @@ public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInt
         super(id, phase);
     }
     
-    protected boolean isRequestor(Message message) {
-        return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
-    }
     protected boolean shouldBuffer(Message message) {
         Object en = message.getContextualProperty(OUT_BUFFERING);
         boolean allowBuffer = true;
@@ -150,7 +144,8 @@ public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInt
                     }
                 }
             }
-        }
+        } 
+
         if (cache != null) {
             try {
                 for (XMLEvent event : cache.getEvents()) {
@@ -161,33 +156,7 @@ public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInt
             }
         }
     }
-    
-    /**
-     * Where an operation level validation type has been set, copy it to the message, so
it can be interrogated
-     * by all downstream interceptors
-     * 
-     * @param bop
-     * @param message
-     * @param reader
-     */
-    private void setOperationSchemaValidation(EndpointInfo ep, OperationInfo opInfo, Message
message) {
-        SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message,
null);
-        if (validationType == null) {
-            if (opInfo != null) {
-                validationType = ServiceUtils.getSchemaValidationType(opInfo);
-                
-                // else fall back to endpoint level schema validation
-                if (validationType == null) {
-                    validationType = ServiceUtils.getSchemaValidationType(ep);
-                }
-                
-                if (validationType != null) {
-                    message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
-                }
-            }
-        }
-    }
-    
+   
     protected boolean shouldValidate(Message m) {
         SchemaValidationType requiredType = isRequestor(m) ? SchemaValidationType.IN : SchemaValidationType.OUT;
         return ServiceUtils.isSchemaValidationEnabled(requiredType, m);

http://git-wip-us.apache.org/repos/asf/cxf/blob/d962278d/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/RPCOutInterceptorTest.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/RPCOutInterceptorTest.java
b/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/RPCOutInterceptorTest.java
index fc356d1..900df20 100644
--- a/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/RPCOutInterceptorTest.java
+++ b/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/RPCOutInterceptorTest.java
@@ -30,12 +30,14 @@ import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.cxf.binding.soap.interceptor.RPCOutInterceptor;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.staxutils.DepthXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -65,8 +67,16 @@ public class RPCOutInterceptorTest extends TestBase {
         BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
         boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
         soapMessage.getExchange().put(BindingOperationInfo.class, boi);
-
+        
         control.reset();
+        
+        Endpoint ep = control.createMock(Endpoint.class);
+        EndpointInfo info = new EndpointInfo();
+        ep.getEndpointInfo();
+        EasyMock.expectLastCall().andReturn(info).anyTimes();
+        soapMessage.getExchange().put(Endpoint.class, ep);
+
+        
         Service service = control.createMock(Service.class);
         EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
         JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);


Mime
View raw message