cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r629442 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/test/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ rt/databinding/aegis/src/main/java/o...
Date Wed, 20 Feb 2008 12:50:09 GMT
Author: bimargulies
Date: Wed Feb 20 04:50:04 2008
New Revision: 629442

URL: http://svn.apache.org/viewvc?rev=629442&view=rev
Log:
Make the use of xmime optional in Aegis.

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/ByteArrayType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java
    incubator/cxf/trunk/systests/src/test/resources/mtomTestBeans.xml

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java Wed Feb
20 04:50:04 2008
@@ -335,6 +335,16 @@
         }
         return null;
     }
+    
+    public Server getServerForAddress(String address) throws WSDLException {
+        ServerRegistry svrMan = bus.getExtension(ServerRegistry.class);
+        for (Server s : svrMan.getServers()) {
+            if (address.equals(s.getEndpoint().getEndpointInfo().getAddress())) {
+                return s;
+            }
+        }
+        return null;
+    }
 
     public static class TestMessageObserver implements MessageObserver {
         ByteArrayOutputStream response = new ByteArrayOutputStream();

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
Wed Feb 20 04:50:04 2008
@@ -83,6 +83,7 @@
     private Map<Class<?>, String> beanImplementationMap;
     private Configuration configuration;
     private boolean mtomEnabled;
+    private boolean mtomUseXmime;
     
     /**
      * Construct a context.
@@ -100,7 +101,7 @@
      */
     public void initialize() {
         if (typeMappingRegistry == null) {
-            typeMappingRegistry = new DefaultTypeMappingRegistry(true);
+            typeMappingRegistry = new DefaultTypeMappingRegistry(null, true, mtomUseXmime);
         } 
         if (configuration != null) {
             typeMappingRegistry.setConfiguration(configuration);
@@ -343,6 +344,18 @@
 
     public void setMtomEnabled(boolean mtomEnabled) {
         this.mtomEnabled = mtomEnabled;
+    }
+
+    /**
+     * Is the schema for MTOM types xmime:base64Binary instead of xsd:base64Binary?
+     * @return
+     */
+    public boolean isMtomUseXmime() {
+        return mtomUseXmime;
+    }
+
+    public void setMtomUseXmime(boolean mtomUseXmime) {
+        this.mtomUseXmime = mtomUseXmime;
     }
 
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
Wed Feb 20 04:50:04 2008
@@ -110,6 +110,7 @@
     private Set<String> overrideTypes;
     private Configuration configuration;
     private boolean mtomEnabled;
+    private boolean mtomUseXmime;
     private JDOMXPath importXmimeXpath;
 
     public AegisDatabinding() {
@@ -159,6 +160,9 @@
                 if (mtomEnabled) {
                     aegisContext.setMtomEnabled(true);
                 }
+                if (mtomUseXmime) {
+                    aegisContext.setMtomUseXmime(true);
+                }
                 aegisContext.initialize();
             }
             isInitialized = true;
@@ -214,9 +218,7 @@
      */
     public void initialize(Service s) {
         
-        // We want to support some compatibility configuration properties
-        // definitionally, anyone doing the compatibility thing has not made their
-        // own AegisContext object.
+        // We want to support some compatibility configuration properties.
         if (aegisContext == null) {
             aegisContext = new AegisContext();
 
@@ -245,6 +247,10 @@
                 aegisContext.setMtomEnabled(true);
             }
             
+            if (mtomUseXmime) {
+                aegisContext.setMtomUseXmime(true);
+            }
+            
             Map<Class<?>, String> implMap = new HashMap<Class<?>, String>();
             // now for a really annoying case, the .implementation objects.
             for (String key : s.keySet()) {
@@ -620,5 +626,13 @@
 
     public void setMtomEnabled(boolean mtomEnabled) {
         this.mtomEnabled = mtomEnabled;
+    }
+
+    public boolean isMtomUseXmime() {
+        return mtomUseXmime;
+    }
+
+    public void setMtomUseXmime(boolean mtomUseXmime) {
+        this.mtomUseXmime = mtomUseXmime;
     }
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
Wed Feb 20 04:50:04 2008
@@ -136,20 +136,25 @@
     private TypeCreator typeCreator;
 
     public DefaultTypeMappingRegistry() {
-        this(false);
+        this(null, false, false);
+    }
+    
+    public DefaultTypeMappingRegistry(TypeCreator typeCreator, boolean createDefault) {
+        this(typeCreator, createDefault, false);
     }
 
     public DefaultTypeMappingRegistry(boolean createDefault) {
-        this(null, createDefault);
+        this(null, createDefault, false);
     }
 
-    public DefaultTypeMappingRegistry(TypeCreator typeCreator, boolean createDefault) {
+    public DefaultTypeMappingRegistry(TypeCreator typeCreator, boolean createDefault, 
+                                      boolean enableMtomXmime) {
         registry = Collections.synchronizedMap(new HashMap<String, TypeMapping>());
 
         this.typeCreator = typeCreator;
 
         if (createDefault) {
-            createDefaultMappings();
+            createDefaultMappings(enableMtomXmime);
         }
     }
 
@@ -286,9 +291,13 @@
     }
 
     public TypeMapping createDefaultMappings() {
+        return createDefaultMappings(false);
+    }
+
+    public TypeMapping createDefaultMappings(boolean enableMtomXmime) {
         TypeMapping tm = createTypeMapping(false);
 
-        createDefaultMappings(tm);
+        createDefaultMappings(enableMtomXmime, tm);
 
         // Create a Type Mapping for SOAP 1.1 Encoding
         TypeMapping soapTM = createTypeMapping(tm, false);
@@ -343,9 +352,8 @@
         register(soapTM, org.jdom.Document.class, XSD_ANY, new JDOMDocumentType());
         register(soapTM, Object.class, XSD_ANY, new ObjectType());
         // unless there is customization, we use no expectedContentTypes.
-        // however, if we want to implement xmime:contentType, we'll need to make this more
complex.
-        register(soapTM, DataSource.class, XSD_BASE64, new DataSourceType(null));
-        register(soapTM, DataHandler.class, XSD_BASE64, new DataHandlerType(null));
+        register(soapTM, DataSource.class, XSD_BASE64, new DataSourceType(enableMtomXmime,
null));
+        register(soapTM, DataHandler.class, XSD_BASE64, new DataHandlerType(enableMtomXmime,
null));
         register(soapTM, BigInteger.class, XSD_INTEGER, new BigIntegerType());
 
         register(ENCODED_NS, soapTM);
@@ -357,6 +365,10 @@
     }
 
     protected void createDefaultMappings(TypeMapping tm) {
+        createDefaultMappings(false, tm);
+    }
+    
+    protected void createDefaultMappings(boolean enableMtomXmime, TypeMapping tm) {
         register(tm, boolean.class, XSD_BOOLEAN, new BooleanType());
         register(tm, int.class, XSD_INT, new IntType());
         register(tm, short.class, XSD_SHORT, new ShortType());
@@ -388,8 +400,16 @@
         register(tm, org.jdom.Document.class, XSD_ANY, new JDOMDocumentType());
         register(tm, Object.class, XSD_ANY, new ObjectType());
 
-        register(tm, DataSource.class, AbstractXOPType.XML_MIME_BASE64, new DataSourceType(null));
-        register(tm, DataHandler.class, AbstractXOPType.XML_MIME_BASE64, new DataHandlerType(null));
+        QName mtomBase64 = XSD_BASE64;
+        if (enableMtomXmime) {
+            mtomBase64 = AbstractXOPType.XML_MIME_BASE64;
+        }
+        
+        
+        register(tm, DataSource.class, mtomBase64, 
+                 new DataSourceType(enableMtomXmime, null));
+        register(tm, DataHandler.class, mtomBase64,
+                 new DataHandlerType(enableMtomXmime, null));
 
         if (isJDK5andAbove()) {
             registerIfAvailable(tm, "javax.xml.datatype.Duration", XSD_DURATION,

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
Wed Feb 20 04:50:04 2008
@@ -45,7 +45,8 @@
 
     public Base64Type() {
         super();
-        optimizedType = new ByteArrayType(null);
+        // no MTOM for this type.
+        optimizedType = new ByteArrayType(false, null);
     }
     
     public Base64Type(AbstractXOPType xopType) {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
Wed Feb 20 04:50:04 2008
@@ -68,12 +68,23 @@
     // the base64 type knows how to deal with just plain base64 here, which is essentially
always 
     // what we get in the absence of the optimization. So we need something of a coroutine.
     private Base64Type fallbackDelegate;
+    private boolean useXmimeBinaryType;
     
-    public AbstractXOPType(String expectedContentTypes) {
+    /**
+     * Create an XOP type. This type will use xmime to publish and receive the content type
+     * via xmime:base64Binary if useXmimeBinaryType is true. If expectedContentTypes != null,
then
+     * it will use xmime to advertise expected content types.
+     * @param useXmimeBinaryType whether to use xmime:base64Binary.
+     * @param expectedContentTypes whether to public xmime:expectedContentTypes.
+     */
+    public AbstractXOPType(boolean useXmimeBinaryType, String expectedContentTypes) {
         this.expectedContentTypes = expectedContentTypes;
+        this.useXmimeBinaryType = useXmimeBinaryType;
         fallbackDelegate = new Base64Type(this);
-        // we use the XMIME type instead of the XSD type to allow for our content type attribute.
-        setSchemaType(XML_MIME_BASE64);
+        if (useXmimeBinaryType) {
+        //      we use the XMIME type instead of the XSD type to allow for our content type
attribute.
+            setSchemaType(XML_MIME_BASE64);
+        }
     }
     
     public static JDOMXPath getXmimeXpathImport() {
@@ -148,7 +159,7 @@
                             Context context) throws DatabindingException {
         // add the content type attribute even if we are going to fall back.
         String contentType = getContentType(object, context);
-        if (contentType != null) {
+        if (contentType != null && useXmimeBinaryType) {
             MessageWriter ctWriter = writer.getAttributeWriter(XML_MIME_CONTENT_TYPE);
             ctWriter.writeValue(contentType);
         }
@@ -209,6 +220,6 @@
     
     @Override
     public boolean usesXmime() {
-        return true;
+        return useXmimeBinaryType || expectedContentTypes != null;
     }
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/ByteArrayType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/ByteArrayType.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/ByteArrayType.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/ByteArrayType.java
Wed Feb 20 04:50:04 2008
@@ -34,8 +34,8 @@
  * @author Dan Diephouse
  */
 public class ByteArrayType extends AbstractXOPType {
-    public ByteArrayType(String expectedContentTypes) {
-        super(expectedContentTypes);
+    public ByteArrayType(boolean useXmimeBinaryType, String expectedContentTypes) {
+        super(useXmimeBinaryType, expectedContentTypes);
         setTypeClass(byte[].class);
     }
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java
Wed Feb 20 04:50:04 2008
@@ -33,8 +33,8 @@
 
 public class DataHandlerType extends AbstractXOPType {
     
-    public DataHandlerType(String expectedContentTypes) {
-        super(expectedContentTypes);
+    public DataHandlerType(boolean useXmimeContentType, String expectedContentTypes) {
+        super(useXmimeContentType, expectedContentTypes);
     }
 
     @Override

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataSourceType.java
Wed Feb 20 04:50:04 2008
@@ -31,8 +31,8 @@
 import org.apache.cxf.message.Attachment;
 
 public class DataSourceType extends AbstractXOPType {
-    public DataSourceType(String expectedContentTypes) {
-        super(expectedContentTypes);
+    public DataSourceType(boolean useXmimeBinaryType, String expectedContentTypes) {
+        super(useXmimeBinaryType, expectedContentTypes);
     }
 
     @Override

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java
Wed Feb 20 04:50:04 2008
@@ -33,6 +33,7 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.type.mtom.AbstractXOPType;
+import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
@@ -126,7 +127,6 @@
         assertEquals("This is the cereal shot from guns.", data);
     }
 
-    // we aren't ready for this one ...
     @Test
     public void testMtomSchema() throws Exception {
         testUtilities.setBus((Bus)applicationContext.getBean("cxf"));
@@ -149,9 +149,26 @@
         assertEquals("base64Binary", pieces[1]);
         Node elementNode = typeAttr.getOwnerElement();
         String url = testUtilities.resolveNamespacePrefix(pieces[0], elementNode);
+        assertEquals(SOAPConstants.XSD, url);
+        
+        s = testUtilities.getServerForAddress("http://localhost:9002/mtomXmime");
+        wsdl = testUtilities.getWSDLDocument(s); 
+        assertNotNull(wsdl);
+        typeAttrList = 
+            testUtilities.assertValid("//xsd:complexType[@name='inputDhBean']/xsd:sequence/"
+                                      + "xsd:element[@name='dataHandler']/"
+                                      + "@type", 
+                                      wsdl);
+        typeAttr = (Attr)typeAttrList.item(0);
+        typeAttrValue = typeAttr.getValue();
+        // now, this thing is a qname with a :, and we have to work out if it's correct.
+        pieces = typeAttrValue.split(":");
+        assertEquals("base64Binary", pieces[1]);
+        elementNode = typeAttr.getOwnerElement();
+        url = testUtilities.resolveNamespacePrefix(pieces[0], elementNode);
         assertEquals(AbstractXOPType.XML_MIME_NS, url);
         
-        /*
+        /* when I add a test for a custom mapping.
         testUtilities.assertValid("//xsd:complexType[@name='inputDhBean']/xsd:sequence/"
                                   + "xsd:element[@name='dataHandler']/"
                                   + "@xmime:expectedContentType/text()", 

Modified: incubator/cxf/trunk/systests/src/test/resources/mtomTestBeans.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/mtomTestBeans.xml?rev=629442&r1=629441&r2=629442&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/resources/mtomTestBeans.xml (original)
+++ incubator/cxf/trunk/systests/src/test/resources/mtomTestBeans.xml Wed Feb 20 04:50:04
2008
@@ -70,5 +70,31 @@
 			</bean>
 		</simple:serviceFactory>
 	</simple:server>
+	
+	<simple:server id="mtom-xmime-server" address="http://localhost:9002/mtomXmime"
+		serviceClass="org.apache.cxf.systest.aegis.mtom.fortest.MtomTest">
+		<simple:dataBinding>
+			<bean
+				class="org.apache.cxf.aegis.databinding.AegisDatabinding">
+				<property name="mtomEnabled" value="true" />
+				<property name="mtomUseXmime" value="true"/>
+			</bean>
+		</simple:dataBinding>
+		<simple:serviceBean>
+			<ref bean="mtomImpl" />
+		</simple:serviceBean>
+		<simple:serviceFactory>
+			<bean
+				class='org.apache.cxf.service.factory.ReflectionServiceFactoryBean'>
+				<property name="properties">
+					<map>
+						<entry key="mtom-enabled">
+							<value>true</value>
+						</entry>
+					</map>
+				</property>
+			</bean>
+		</simple:serviceFactory>
+	</simple:server>
 
 </beans>



Mime
View raw message