cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r732106 - in /cxf/trunk/rt/databinding/aegis: ./ src/main/java/org/apache/cxf/aegis/ src/main/java/org/apache/cxf/aegis/type/ src/test/java/org/apache/cxf/aegis/ src/test/java/org/apache/cxf/aegis/integration/ src/test/java/org/apache/cxf/a...
Date Tue, 06 Jan 2009 20:41:57 GMT
Author: bimargulies
Date: Tue Jan  6 12:41:56 2009
New Revision: 732106

URL: http://svn.apache.org/viewvc?rev=732106&view=rev
Log:
Make JDOM entirely optional in Aegis.

Modified:
    cxf/trunk/rt/databinding/aegis/pom.xml
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/streams/XMLStreamReaderMappingTest.java
    cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/type/aegisOptionsTestBeans.xml

Modified: cxf/trunk/rt/databinding/aegis/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/pom.xml?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/pom.xml (original)
+++ cxf/trunk/rt/databinding/aegis/pom.xml Tue Jan  6 12:41:56 2009
@@ -82,6 +82,7 @@
             <groupId>jdom</groupId>
             <artifactId>jdom</artifactId>
             <version>${jdom.version}</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>junit</groupId>

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java Tue
Jan  6 12:41:56 2009
@@ -92,6 +92,7 @@
     private TypeCreationOptions configuration;
     private boolean mtomEnabled;
     private boolean mtomUseXmime;
+    private boolean enableJDOMMappings;
     // this URI goes into the type map.
     private String mappingNamespaceURI;
 
@@ -140,7 +141,9 @@
         }
         if (typeMapping == null) {
             boolean defaultNillable = configuration.isDefaultNillable();
-            TypeMapping baseTM = DefaultTypeMapping.createDefaultTypeMapping(defaultNillable,
mtomUseXmime);
+            TypeMapping baseTM = DefaultTypeMapping.createDefaultTypeMapping(defaultNillable,

+                                                                             mtomUseXmime,

+                                                                             enableJDOMMappings);
             // The use of the XSD URI in the mapping is, MAGIC.
             if (mappingNamespaceURI == null) {
                 mappingNamespaceURI = SOAPConstants.XSD;
@@ -461,4 +464,16 @@
     public void setMappingNamespaceURI(String mappingNamespaceURI) {
         this.mappingNamespaceURI = mappingNamespaceURI;
     }
+
+    public boolean isEnableJDOMMappings() {
+        return enableJDOMMappings;
+    }
+    
+    /**
+     * Whether to enable JDOM as a mapping for xsd:anyType if JDOM is in the classpath. 
+     * @param enableJDOMMappings
+     */
+    public void setEnableJDOMMappings(boolean enableJDOMMappings) {
+        this.enableJDOMMappings = enableJDOMMappings;
+    }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
Tue Jan  6 12:41:56 2009
@@ -68,9 +68,9 @@
 import org.apache.cxf.aegis.type.xml.SourceType;
 import org.apache.cxf.aegis.type.xml.XMLStreamReaderType;
 import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.common.util.XMLSchemaQNames;
-import org.jdom.Element;
 
 /**
  * Contains type mappings for java/qname pairs.
@@ -224,7 +224,7 @@
     }
 
     private static void fillStandardMappings(TypeMapping tm, boolean defaultNillable, 
-                                             boolean enableMtomXmime) {
+                                             boolean enableMtomXmime, boolean enableJDOM)
{
         defaultRegister(tm, defaultNillable, BigDecimal.class, XMLSchemaQNames.XSD_DECIMAL,
                         new BigDecimalType());
         defaultRegister(tm, defaultNillable, BigInteger.class, XMLSchemaQNames.XSD_INTEGER,
@@ -234,9 +234,6 @@
         defaultRegister(tm, defaultNillable, Calendar.class, XMLSchemaQNames.XSD_DATETIME,
                         new CalendarType());
         defaultRegister(tm, defaultNillable, Date.class, XMLSchemaQNames.XSD_DATETIME, new
DateTimeType());
-        defaultRegister(tm, defaultNillable, Document.class, XMLSchemaQNames.XSD_ANY, new
DocumentType());
-        defaultRegister(tm, defaultNillable, Element.class, XMLSchemaQNames.XSD_ANY,
-                        new JDOMElementType());
         defaultRegister(tm, defaultNillable, Float.class, XMLSchemaQNames.XSD_FLOAT, new
FloatType());
         defaultRegister(tm, defaultNillable, Double.class, XMLSchemaQNames.XSD_DOUBLE, new
DoubleType());
         defaultRegister(tm, defaultNillable, Integer.class, XMLSchemaQNames.XSD_INT, new
IntType());
@@ -265,8 +262,6 @@
 
         defaultRegister(tm, defaultNillable, java.sql.Date.class, XMLSchemaQNames.XSD_DATETIME,
                         new SqlDateType());
-        defaultRegister(tm, defaultNillable, org.jdom.Document.class, XMLSchemaQNames.XSD_ANY,
-                        new JDOMDocumentType());
         
         QName mtomBase64 = XMLSchemaQNames.XSD_BASE64;
         if (enableMtomXmime) {
@@ -277,13 +272,56 @@
                         new DataSourceType(enableMtomXmime, null));
         defaultRegister(tm, defaultNillable, DataHandler.class, mtomBase64,
                         new DataHandlerType(enableMtomXmime, null));
+        
+
+        defaultRegister(tm, defaultNillable, Document.class, XMLSchemaQNames.XSD_ANY, new
DocumentType());
+        if (enableJDOM) {
+            registerJDOMTypes(tm, defaultNillable);
+        }
+
+    }
+
+    private static void registerJDOMTypes(TypeMapping tm, boolean defaultNillable) {
+        try {
+            Class<?> jdomDocClass = ClassLoaderUtils.loadClass("org.jdom.Document",
DefaultTypeMapping.class);
+            defaultRegister(tm, defaultNillable, jdomDocClass, XMLSchemaQNames.XSD_ANY,
+                            new JDOMDocumentType());
+
+        } catch (ClassNotFoundException e) {
+            // not available.
+        }
+        
+        try {
+            Class<?> jdomElementClass = 
+                ClassLoaderUtils.loadClass("org.jdom.Element", DefaultTypeMapping.class);
+            defaultRegister(tm, defaultNillable, jdomElementClass, XMLSchemaQNames.XSD_ANY,
+                                new JDOMElementType());
+        } catch (ClassNotFoundException e) {
+            // not available.
+        }
+    }
+
+    public static DefaultTypeMapping createSoap11TypeMapping(boolean defaultNillable, 
+     boolean enableMtomXmime) {
+        return createSoap11TypeMapping(
+                                       defaultNillable,
+                                       enableMtomXmime,
+                                       false);
     }
 
+    /**
+     * Create a type mapping object with a stock set of mappings, including the SOAP 1.1
'encoded'
+     * types.
+     * @param defaultNillable whether elements are nillable by default.
+     * @param enableMtomXmime whether to enable XMIME annotations with MTOM.
+     * @param enableJDOM whether to add mappings for JDOM.
+     * @return
+     */
     public static DefaultTypeMapping createSoap11TypeMapping(boolean defaultNillable, 
-                                                             boolean enableMtomXmime) {
+                                                             boolean enableMtomXmime, boolean
enableJDOM) {
         // Create a Type Mapping for SOAP 1.1 Encoding
         DefaultTypeMapping soapTM = new DefaultTypeMapping(Soap11.SOAP_ENCODING_URI);
-        fillStandardMappings(soapTM, defaultNillable, enableMtomXmime);
+        fillStandardMappings(soapTM, defaultNillable, enableMtomXmime, enableJDOM);
 
         defaultRegister(soapTM, defaultNillable, boolean.class, Soap11.ENCODED_BOOLEAN, new
BooleanType());
         defaultRegister(soapTM, defaultNillable, char.class, Soap11.ENCODED_CHAR, new CharacterType());
@@ -315,10 +353,26 @@
     }
 
     public static DefaultTypeMapping createDefaultTypeMapping(boolean defaultNillable, 
-                                                              boolean enableMtomXmime) {
+      boolean enableMtomXmime) {
+        return createDefaultTypeMapping(
+                                        defaultNillable,
+                                        enableMtomXmime,
+                                        false);
+    }
+
+    /**
+     * Create a set of default type mappings.
+     * @param defaultNillable whether elements are nillable by default.
+     * @param enableMtomXmime whether to enable XMIME annotations on MTOM.
+     * @param enableJDOM whether to map JDOM types.
+     * @return
+     */
+    public static DefaultTypeMapping createDefaultTypeMapping(boolean defaultNillable, 
+                                                              boolean enableMtomXmime, 
+                                                              boolean enableJDOM) {
         // by convention, the default mapping is against the XML schema URI.
         DefaultTypeMapping tm = new DefaultTypeMapping(SOAPConstants.XSD);
-        fillStandardMappings(tm, defaultNillable, enableMtomXmime);
+        fillStandardMappings(tm, defaultNillable, enableMtomXmime, enableJDOM);
         defaultRegister(tm, defaultNillable, Character.class, 
                         CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME,
                         new CharacterAsStringType());

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
Tue Jan  6 12:41:56 2009
@@ -74,6 +74,7 @@
 
 public abstract class AbstractAegisTest extends AbstractCXFTest {
     protected LocalTransportFactory localTransport;
+    private boolean enableJDOM;
 
     @Before
     public void setUp() throws Exception {
@@ -205,7 +206,14 @@
     @SuppressWarnings("deprecation")
     protected void setupAegis(AbstractWSDLBasedEndpointFactory sf, AegisDatabinding binding)
{
         if (binding == null) {
+            AegisContext context = new AegisContext();
+            if (enableJDOM) {
+                context.setEnableJDOMMappings(true);
+            }
             binding = new AegisDatabinding();
+            if (enableJDOM) { // this preserves pre-2.1 behavior.
+                binding.setAegisContext(context);
+            }
         }
         sf.getServiceFactory().getServiceConfigurations()
             .add(0, new org.apache.cxf.aegis.databinding.AegisServiceConfiguration());
@@ -312,5 +320,13 @@
         writer.close();
         return element;
     }
+
+    protected boolean isEnableJDOM() {
+        return enableJDOM;
+    }
+
+    protected void setEnableJDOM(boolean enableJDOM) {
+        this.enableJDOM = enableJDOM;
+    }
     
 }

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java
Tue Jan  6 12:41:56 2009
@@ -40,6 +40,7 @@
     @Before 
     public void setUp() throws Exception {
         super.setUp();
+        setEnableJDOM(true); // there are JDOM types in here.
         createService(AddNumbers.class, "AddNumbers", null);
         createService(ArrayService.class, "ArrayService", null);
     }

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
Tue Jan  6 12:41:56 2009
@@ -41,6 +41,7 @@
     @Before 
     public void setUp() throws Exception {
         super.setUp();
+        setEnableJDOM(true);
         arrayService = new ArrayService();
         createService(BeanService.class, "BeanService");
         createService(ArrayService.class, arrayService, "Array", new QName("urn:Array", "Array"));

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java
Tue Jan  6 12:41:56 2009
@@ -59,7 +59,7 @@
 
         AegisContext context = new AegisContext();
         // create a different mapping than the context creates.
-        TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false);
+        TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false,
false);
         mapping = new DefaultTypeMapping(SOAPConstants.XSD, baseMapping);
         mapping.setTypeCreator(context.createTypeCreator());
         context.setTypeMapping(mapping);

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/streams/XMLStreamReaderMappingTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/streams/XMLStreamReaderMappingTest.java?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/streams/XMLStreamReaderMappingTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/streams/XMLStreamReaderMappingTest.java
Tue Jan  6 12:41:56 2009
@@ -48,7 +48,7 @@
 
         context = new AegisContext();
         // create a different mapping than the context creates.
-        TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false);
+        TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false,
false);
         mapping = new DefaultTypeMapping(SOAPConstants.XSD, baseMapping);
         mapping.register(XMLStreamReader.class, 
                          new QName("urn:Bean", "SimpleBean"), new XMLStreamReaderType());

Modified: cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/type/aegisOptionsTestBeans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/type/aegisOptionsTestBeans.xml?rev=732106&r1=732105&r2=732106&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/type/aegisOptionsTestBeans.xml
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/type/aegisOptionsTestBeans.xml
Tue Jan  6 12:41:56 2009
@@ -35,11 +35,17 @@
 	<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
 
         <bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding">
-                <property name="configuration">
-                        <bean class="org.apache.cxf.aegis.type.TypeCreationOptions">
-                        <property name="defaultMinOccurs" value="3"/>
-                        <property name="defaultNillable" value="false"/>
-                        </bean>
+                <property name="aegisContext">
+                	<bean class="org.apache.cxf.aegis.AegisContext">
+                	<!--  the test that uses this uses JDOM -->
+                		<property name="enableJDOMMappings" value="true"/>
+                		<property name="configuration">
+	                        <bean class="org.apache.cxf.aegis.type.TypeCreationOptions">
+                        		<property name="defaultMinOccurs" value="3"/>
+                        		<property name="defaultNillable" value="false"/>
+                        	</bean>
+                		</property>
+                	</bean>
                 </property>
         </bean>
            



Mime
View raw message