cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r694981 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/service/ 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/org/apac...
Date Sat, 13 Sep 2008 16:40:19 GMT
Author: bimargulies
Date: Sat Sep 13 09:40:18 2008
New Revision: 694981

URL: http://svn.apache.org/viewvc?rev=694981&view=rev
Log:
Replace use of SOAP-encoding for char with a specialization of integer.


Added:
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java
  (with props)
    cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml   (with props)
Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java
    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/databinding/AegisDatabinding.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterAsStringType.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
    cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java Sat Sep 13 09:40:18
2008
@@ -117,4 +117,9 @@
     public void setProperties(Map<String, Object> properties) {
         this.putAll(properties);
     }
+    
+    @Override
+    public String toString() {
+        return "[ServiceImpl " + getName() + "]";
+    }
 }

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=694981&r1=694980&r2=694981&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 Sat
Sep 13 09:40:18 2008
@@ -18,15 +18,21 @@
  */
 package org.apache.cxf.aegis;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.w3c.dom.Document;
+
+import org.xml.sax.SAXException;
+
 import org.apache.cxf.aegis.type.AbstractTypeCreator;
 import org.apache.cxf.aegis.type.DefaultTypeCreator;
 import org.apache.cxf.aegis.type.DefaultTypeMapping;
@@ -40,40 +46,48 @@
 import org.apache.cxf.aegis.type.java5.Java5TypeCreator;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.util.SOAPConstants;
+import org.apache.cxf.helpers.DOMUtils;
+import org.jaxen.JaxenException;
+import org.jaxen.jdom.JDOMXPath;
+import org.jdom.Element;
+import org.jdom.Namespace;
 
 /**
- * The Aegis Databinding context object. This object coordinates the data binding process:
reading
- * and writing XML.
- * 
- * By default, this object sets up a default set of type mappings. 
- * This consists of two DefaultTypeMapping objects. The first is empty
- * and has the Default, Java5, and XML TypeCreator classes configured. The second contains
the
- * standard mappings of the stock types. If a type can't be mapped in either, then the creators

- * create a mapping and store it in the first one.
- * 
- * The application can control some parameters of the type creators by creating a TypeCreationOptions
- * object and setting properties. The application can add custom mappings to the type mapping,
or 
- * even use its own classes for the TypeMapping or TypeCreator objects.
- *
- * Aegis, unlike JAXB, has no concept of a 'root element'. So, an application that 
- * uses Aegis without a web service has to either depend on xsi:type (at least for 
- * root elements) or have its own mapping from elements to classes, and pass the 
- * resulting Class objects to the readers.
- * At this level, the application must specify the initial set of classes to make 
- * make use of untyped collections or .aegis.xml files.
- * 
- * If the application leaves this list empty, and reads XML messages, then no .aegis.xml
files 
- * are used unless the application has specified a Class&lt;T&gt; for the root of
a 
- * particular item read. Specifically, if the application just leaves it to Aegis to
- * map an element tagged with an xsi:type to a class, Aegis can't know that some arbitrary
class in
- * some arbitrary package is mapped to a particular schema type by QName in a
- * mapping XML file.
- * 
- * At the level of the CXF data binding, the 'root elements' are defined by the WSDL message
parts.
- * Additional classes that participate are termed 'override' classes.
- * 
+ * The Aegis Databinding context object. This object coordinates the data binding process:
reading and writing
+ * XML. By default, this object sets up a default set of type mappings. This consists of
two
+ * DefaultTypeMapping objects. The first is empty and has the Default, Java5, and XML TypeCreator
classes
+ * configured. The second contains the standard mappings of the stock types. If a type can't
be mapped in
+ * either, then the creators create a mapping and store it in the first one. The application
can control some
+ * parameters of the type creators by creating a TypeCreationOptions object and setting properties.
The
+ * application can add custom mappings to the type mapping, or even use its own classes for
the TypeMapping or
+ * TypeCreator objects. Aegis, unlike JAXB, has no concept of a 'root element'. So, an application
that uses
+ * Aegis without a web service has to either depend on xsi:type (at least for root elements)
or have its own
+ * mapping from elements to classes, and pass the resulting Class objects to the readers.
At this level, the
+ * application must specify the initial set of classes to make make use of untyped collections
or .aegis.xml
+ * files. If the application leaves this list empty, and reads XML messages, then no .aegis.xml
files are used
+ * unless the application has specified a Class&lt;T&gt; for the root of a particular
item read. Specifically,
+ * if the application just leaves it to Aegis to map an element tagged with an xsi:type to
a class, Aegis
+ * can't know that some arbitrary class in some arbitrary package is mapped to a particular
schema type by
+ * QName in a mapping XML file. At the level of the CXF data binding, the 'root elements'
are defined by the
+ * WSDL message parts. Additional classes that participate are termed 'override' classes.
  */
 public class AegisContext {
+
+    /**
+     * Namespace used for miscellaneous Aegis types.
+     */
+    public static final String SCHEMA_NS = "http://cxf.apache.org/aegisTypes";
+    private static JDOMXPath importTypesXpath;
+
+    static {
+        try {
+            importTypesXpath = new JDOMXPath("xsd:import[@namespace='" + SCHEMA_NS + "']");
+            importTypesXpath.addNamespace(SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        } catch (JaxenException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
     private boolean writeXsiTypes;
     private boolean readXsiTypes = true;
 
@@ -89,6 +103,8 @@
     private boolean mtomUseXmime;
     // this URI goes into the type map.
     private String mappingNamespaceURI;
+    private Document typesSchemaDocument;
+
     /**
      * Construct a context.
      */
@@ -97,7 +113,7 @@
         rootClasses = new HashSet<Class<?>>();
         rootTypeQNames = new HashSet<QName>();
     }
-    
+
     public TypeCreator createTypeCreator() {
         AbstractTypeCreator xmlCreator = createRootTypeCreator();
 
@@ -121,10 +137,10 @@
         return creator;
     }
 
-
     /**
-     * Initialize the context. The encodingStyleURI allows .aegis.xml files to have multiple
mappings 
-     * for, say, SOAP 1.1 versus SOAP 1.2. Passing null uses a default URI. 
+     * Initialize the context. The encodingStyleURI allows .aegis.xml files to have multiple
mappings for,
+     * say, SOAP 1.1 versus SOAP 1.2. Passing null uses a default URI.
+     * 
      * @param mappingNamespaceURI URI to select mappings based on the encoding.
      */
     public void initialize() {
@@ -135,7 +151,7 @@
         if (typeMapping == null) {
             boolean defaultNillable = configuration.isDefaultNillable();
             TypeMapping baseTM = DefaultTypeMapping.createDefaultTypeMapping(defaultNillable,
mtomUseXmime);
-            // The use of the XSD URI in the mapping is, MAGIC. 
+            // The use of the XSD URI in the mapping is, MAGIC.
             if (mappingNamespaceURI == null) {
                 mappingNamespaceURI = SOAPConstants.XSD;
             }
@@ -143,34 +159,29 @@
             defaultTypeMapping.setTypeCreator(createTypeCreator());
             typeMapping = defaultTypeMapping;
         }
-        
+
         processRootTypes();
     }
-    
-    
-    public AegisReader<org.w3c.dom.Element>
-    createDomElementReader() {
+
+    public AegisReader<org.w3c.dom.Element> createDomElementReader() {
         return new AegisElementDataReader(this);
     }
-    
-    public AegisReader<XMLStreamReader>
-    createXMLStreamReader() {
+
+    public AegisReader<XMLStreamReader> createXMLStreamReader() {
         return new AegisXMLStreamDataReader(this);
     }
-    
-    public AegisWriter<org.w3c.dom.Element>
-    createDomElementWriter() {
+
+    public AegisWriter<org.w3c.dom.Element> createDomElementWriter() {
         return new AegisElementDataWriter(this);
     }
-    
-    public AegisWriter<XMLStreamWriter>
-    createXMLStreamWriter() {
+
+    public AegisWriter<XMLStreamWriter> createXMLStreamWriter() {
         return new AegisXMLStreamDataWriter(this);
     }
-    
+
     /**
-     * If a class was provided as part of the 'root' list, retrieve it's Type by
-     * Class.
+     * If a class was provided as part of the 'root' list, retrieve it's Type by Class.
+     * 
      * @param clazz
      * @return
      */
@@ -181,10 +192,10 @@
             return null;
         }
     }
-    
+
     /**
-     * If a class was provided as part of the root list, retrieve it's Type by schema
-     * type QName.
+     * If a class was provided as part of the root list, retrieve it's Type by schema type
QName.
+     * 
      * @param schemaTypeName
      * @return
      */
@@ -195,10 +206,11 @@
             return null;
         }
     }
-    
+
     /**
      * Examine a list of override classes, and register all of them.
-     * @param tm      type manager for this binding
+     * 
+     * @param tm type manager for this binding
      * @param classes list of class names
      */
     private void processRootTypes() {
@@ -216,11 +228,11 @@
                 } catch (ClassNotFoundException e) {
                     throw new DatabindingException("Could not find override type class: "
+ typeName, e);
                 }
-                
+
                 rootClasses.add(c);
             }
         }
-         
+
         for (Class<?> c : rootClasses) {
             Type t = typeMapping.getType(c);
             if (t == null) {
@@ -236,20 +248,58 @@
         }
     }
 
+    public static boolean schemaImportsUtilityTypes(Element schemaElement) {
+        try {
+            return importTypesXpath.selectSingleNode(schemaElement) != null;
+        } catch (JaxenException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public Document getTypesSchemaDocument() {
+        ensureTypesSchemaDocument();
+        return typesSchemaDocument;
+    }
+
+    private void ensureTypesSchemaDocument() {
+        if (typesSchemaDocument != null) {
+            return;
+        }
+        try {
+            typesSchemaDocument = DOMUtils.readXml(getClass()
+                .getResourceAsStream("/META-INF/cxf/aegisTypes.xsd"));
+        } catch (SAXException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static void addUtilityTypesToSchema(Element root) {
+        if (schemaImportsUtilityTypes(root)) {
+            return;
+        }
+        Element element = new Element("import", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        root.addContent(0, element);
+        element.setAttribute("namespace", SCHEMA_NS);
+        root.addNamespaceDeclaration(Namespace.getNamespace("aegisTypes", SCHEMA_NS));
+    }
+
     /**
-     * Retrieve the set of root class names. Note that if the application
-     * specifies the root classes by Class instead of by name, this will
-     * return null.
+     * Retrieve the set of root class names. Note that if the application specifies the root
classes by Class
+     * instead of by name, this will return null.
+     * 
      * @return
      */
     public Set<String> getRootClassNames() {
         return rootClassNames;
     }
-    
+
     /**
-     * Set the root class names. This function is a convenience for Spring
-     * configuration. It sets the same underlying 
-     * collection as {@link #setRootClasses(Set)}.
+     * Set the root class names. This function is a convenience for Spring configuration.
It sets the same
+     * underlying collection as {@link #setRootClasses(Set)}.
      * 
      * @param classNames
      */
@@ -257,8 +307,9 @@
         rootClassNames = classNames;
     }
 
-    /** 
+    /**
      * Return the type mapping configuration associated with this context.
+     * 
      * @return Returns the configuration.
      * @deprecated 2.1
      */
@@ -266,8 +317,9 @@
         return configuration;
     }
 
-    /** 
+    /**
      * Return the type mapping configuration associated with this context.
+     * 
      * @return Returns the configuration.
      */
     public TypeCreationOptions getTypeCreationOptions() {
@@ -275,8 +327,8 @@
     }
 
     /**
-     * Set the configuration object. The configuration specifies default
-     * type mapping behaviors. 
+     * Set the configuration object. The configuration specifies default type mapping behaviors.
+     * 
      * @param configuration The configuration to set.
      * @deprecated 2.1
      */
@@ -285,8 +337,8 @@
     }
 
     /**
-     * Set the configuration object. The configuration specifies default
-     * type mapping behaviors.
+     * Set the configuration object. The configuration specifies default type mapping behaviors.
+     * 
      * @param configuration The configuration to set.
      */
     public void setTypeCreationOptions(TypeCreationOptions newConfiguration) {
@@ -302,8 +354,8 @@
     }
 
     /**
-     * Controls whether Aegis writes xsi:type attributes on all elements.
-     * False by default.
+     * Controls whether Aegis writes xsi:type attributes on all elements. False by default.
+     * 
      * @param flag
      */
     public void setWriteXsiTypes(boolean flag) {
@@ -311,9 +363,9 @@
     }
 
     /**
-     * Controls the use of xsi:type attributes when reading objects. By default,
-     * xsi:type reading is enabled. When disabled, Aegis will only map for objects
-     * that the application manually maps in the type mapping. 
+     * Controls the use of xsi:type attributes when reading objects. By default, xsi:type
reading is enabled.
+     * When disabled, Aegis will only map for objects that the application manually maps
in the type mapping.
+     * 
      * @param flag
      */
     public void setReadXsiTypes(boolean flag) {
@@ -322,6 +374,7 @@
 
     /**
      * Return the type mapping object used by this context.
+     * 
      * @return
      */
     public TypeMapping getTypeMapping() {
@@ -330,6 +383,7 @@
 
     /**
      * Set the type mapping object used by this context.
+     * 
      * @param typeMapping
      */
     public void setTypeMapping(TypeMapping typeMapping) {
@@ -338,16 +392,17 @@
 
     /**
      * Retrieve the Aegis type objects for the root classes.
+     * 
      * @return the set of type objects.
      */
     public Set<Type> getRootTypes() {
         return rootTypes;
     }
-    
-    
-    /** 
-     * This property provides support for interfaces. If there is a mapping from an interface's
Class<T>
-     * to a string containing a class name, Aegis will create proxy objects of that class
name.
+
+    /**
+     * This property provides support for interfaces. If there is a mapping from an interface's
Class<T> to a
+     * string containing a class name, Aegis will create proxy objects of that class name.
+     * 
      * @see org.apache.cxf.aegis.type.basic.BeanType
      * @return
      */
@@ -365,6 +420,7 @@
 
     /**
      * The list of initial classes.
+     * 
      * @param rootClasses
      */
     public void setRootClasses(Set<Class<?>> rootClasses) {
@@ -373,6 +429,7 @@
 
     /**
      * Is MTOM enabled in this context?
+     * 
      * @return
      */
     public boolean isMtomEnabled() {
@@ -385,6 +442,7 @@
 
     /**
      * Should this service use schema for MTOM types xmime:base64Binary instead of xsd:base64Binary?
+     * 
      * @return
      */
     public boolean isMtomUseXmime() {
@@ -396,10 +454,10 @@
     }
 
     /**
-     * What URI identifies the type mapping for this context? 
-     * When the XMLTypeCreator reads .aegis.xml file, it will only read mappings for
-     * this URI (or no URI). When the abstract type creator is otherwise at a loss
-     * for a namespace URI, it will use this URI.
+     * What URI identifies the type mapping for this context? When the XMLTypeCreator reads
.aegis.xml file,
+     * it will only read mappings for this URI (or no URI). When the abstract type creator
is otherwise at a
+     * loss for a namespace URI, it will use this URI.
+     * 
      * @return
      */
     public String getMappingNamespaceURI() {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
Sat Sep 13 09:40:18 2008
@@ -104,7 +104,7 @@
      * @deprecated 2.1
      */
     public static final String READ_XSI_TYPE_KEY = "readXsiType";
-
+    
     protected static final int IN_PARAM = 0;
     protected static final int OUT_PARAM = 1;
     protected static final int FAULT_PARAM = 2;
@@ -460,6 +460,8 @@
 
         Map<String, String> namespaceMap = getDeclaredNamespaceMappings();
         boolean needXmimeSchema = false;
+        // utility types.
+        boolean needTypesSchema = false;
 
         for (Map.Entry<String, Set<Type>> entry : tns2Type.entrySet()) {
             String xsdPrefix = SOAPConstants.XSD_PREFIX;
@@ -501,6 +503,9 @@
             if (schemaImportsXmime(e)) {
                 needXmimeSchema = true;
             }
+            if (AegisContext.schemaImportsUtilityTypes(e)) {
+                needTypesSchema = true;
+            }
 
             try {
                 NamespaceMap nsMap = new NamespaceMap();
@@ -545,6 +550,15 @@
                 addSchemaDocument(si, col, xmimeSchemaDocument, AbstractXOPType.XML_MIME_NS);
             }
         }
+        
+        if (needTypesSchema) {
+            org.w3c.dom.Document schema = aegisContext.getTypesSchemaDocument(); 
+            for (ServiceInfo si : s.getServiceInfos()) {
+                SchemaCollection col = si.getXmlSchemaCollection();
+                addSchemaDocument(si, col, schema, AegisContext.SCHEMA_NS);
+            }
+        }
+        
     }
 
     public QName getSuggestedName(Service s, TypeMapping tm, OperationInfo op, int param)
{

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=694981&r1=694980&r2=694981&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
Sat Sep 13 09:40:18 2008
@@ -45,6 +45,7 @@
 import org.apache.cxf.aegis.type.basic.BigIntegerType;
 import org.apache.cxf.aegis.type.basic.BooleanType;
 import org.apache.cxf.aegis.type.basic.CalendarType;
+import org.apache.cxf.aegis.type.basic.CharacterAsStringType;
 import org.apache.cxf.aegis.type.basic.CharacterType;
 import org.apache.cxf.aegis.type.basic.DateTimeType;
 import org.apache.cxf.aegis.type.basic.DoubleType;
@@ -230,7 +231,6 @@
                         new BooleanType());
         defaultRegister(tm, defaultNillable, Calendar.class, XMLSchemaQNames.XSD_DATETIME,
                         new CalendarType());
-        defaultRegister(tm, defaultNillable, Character.class, Soap11.ENCODED_CHAR, new CharacterType());
         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,
@@ -282,6 +282,7 @@
         fillStandardMappings(soapTM, defaultNillable, enableMtomXmime);
 
         defaultRegister(soapTM, defaultNillable, boolean.class, Soap11.ENCODED_BOOLEAN, new
BooleanType());
+        defaultRegister(soapTM, defaultNillable, char.class, Soap11.ENCODED_CHAR, new CharacterType());
         defaultRegister(soapTM, defaultNillable, int.class, Soap11.ENCODED_INT, new IntType());
         defaultRegister(soapTM, defaultNillable, short.class, Soap11.ENCODED_SHORT, new ShortType());
         defaultRegister(soapTM, defaultNillable, double.class, Soap11.ENCODED_DOUBLE, new
DoubleType());
@@ -314,6 +315,12 @@
         // by convention, the default mapping is against the XML schema URI.
         DefaultTypeMapping tm = new DefaultTypeMapping(SOAPConstants.XSD);
         fillStandardMappings(tm, defaultNillable, enableMtomXmime);
+        defaultRegister(tm, defaultNillable, Character.class, 
+                        CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME,
+                        new CharacterAsStringType());
+        defaultRegister(tm, defaultNillable, char.class, 
+                        CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME,
+                        new CharacterAsStringType());
 
         registerIfAvailable(tm, defaultNillable, "javax.xml.datatype.Duration", XMLSchemaQNames.XSD_DURATION,
                             "org.apache.cxf.aegis.type.java5.DurationType");

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java Sat Sep
13 09:40:18 2008
@@ -213,6 +213,14 @@
         return false;
     }
     
+    /**
+     * True if this type requires the import of the aegisTypes schema.
+     * @return
+     */
+    public boolean usesUtilityTypes() {
+        return false;
+    }
+    
     public boolean hasMinOccurs() {
         return false;
     }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
Sat Sep 13 09:40:18 2008
@@ -30,6 +30,7 @@
 import java.util.Set;
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.Context;
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.Type;
@@ -454,6 +455,7 @@
 
         Element seq = null;
         boolean needXmime = false;
+        boolean needUtilityTypes = false;
         
         // Write out schema for elements
         for (Iterator itr = inf.getElements(); itr.hasNext();) {
@@ -486,11 +488,16 @@
 
             writeTypeReference(name, nameWithPrefix, element, type, prefix, root);
             needXmime |= type.usesXmime();
+            needUtilityTypes |= type.usesUtilityTypes();
         }
         
         if (needXmime) {
             addXmimeToSchema(root);
         }
+        
+        if (needUtilityTypes) {
+            AegisContext.addUtilityTypesToSchema(root);
+        }
 
         /**
          * if future proof then add <xsd:any/> element

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterAsStringType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterAsStringType.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterAsStringType.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterAsStringType.java
Sat Sep 13 09:40:18 2008
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.aegis.type.basic;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.aegis.Context;
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.Type;
@@ -30,20 +32,20 @@
  */
 public class CharacterAsStringType extends Type {
     
-    private StringType stringType;
+    public static final QName CHARACTER_AS_STRING_TYPE_QNAME 
+        = new QName("http://cxf.apache.org/aegisTypes", "char");
+    
+    private IntType intType;
     
     public CharacterAsStringType() {
-        stringType = new StringType();
+        intType = new IntType();
     }
 
     /** {@inheritDoc}*/
     @Override
     public Object readObject(MessageReader reader, Context context) throws DatabindingException
{
-        String string = (String)stringType.readObject(reader, context);
-        if (string.length() == 0) {
-            return Character.valueOf((char)0);
-        }
-        return new Character(string.charAt(0));
+        Integer readInteger = (Integer)intType.readObject(reader, context);
+        return new Character((char)readInteger.intValue());
     }
 
     /** {@inheritDoc}*/
@@ -51,6 +53,12 @@
     public void writeObject(Object object, MessageWriter writer, Context context) 
         throws DatabindingException {
         Character charObject = (Character) object;
-        stringType.writeObject(charObject.toString(), writer, context);
+        intType.writeObject(Integer.valueOf(charObject.charValue()), writer, context);
+    }
+
+    @Override
+    public boolean usesUtilityTypes() {
+        return true;
     }
+
 }

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
Sat Sep 13 09:40:18 2008
@@ -31,6 +31,7 @@
     private int[] numbers;
     
     private Character character;
+    private char primitiveCharacter;
 
     public int[] getNumbers() {
         return numbers;
@@ -73,4 +74,12 @@
     public void setCharacter(Character character) {
         this.character = character;
     }
+
+    public char getPrimitiveChar() {
+        return primitiveCharacter;
+    }
+
+    public void setPrimitiveChar(char pchar) {
+        this.primitiveCharacter = pchar;
+    }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
Sat Sep 13 09:40:18 2008
@@ -25,6 +25,9 @@
 
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Attr;
+import org.w3c.dom.NodeList;
+
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.Context;
@@ -329,6 +332,37 @@
         assertInvalid("//xsd:complexType[@name='IntBean']/xsd:sequence/xsd:element[@name='int1'][@nillable]",
                       schema);
     }
+    
+    @Test
+    public void testCharMappings() throws Exception {
+        context = new AegisContext();
+        context.initialize();
+        mapping = context.getTypeMapping();
+
+        BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+
+        Element types = new Element("types", "xsd", SOAPConstants.XSD);
+        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
+        type.writeSchema(schema);
+
+        NodeList typeAttrNode = 
+            assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence/xsd:element[@name='character']"
+                       + "/@type", 
+                       schema); 
+        assertEquals(1, typeAttrNode.getLength());
+        Attr typeAttr = (Attr)typeAttrNode.item(0);
+        String typeQnameString = typeAttr.getValue();
+        String[] pieces = typeQnameString.split(":");
+        assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME.getLocalPart(),
+                     pieces[1]);
+    }
+    
     @Test
     public void testNullNonNillableWithDate() throws Exception {
         BeanTypeInfo info = new BeanTypeInfo(DateBean.class, "urn:Bean");
@@ -363,7 +397,7 @@
         type.setSchemaType(new QName("urn:Bean", "bean"));
 
         PropertyDescriptor[] pds = info.getPropertyDescriptors();
-        assertEquals(5, pds.length);
+        assertEquals(6, pds.length);
 
         ExtendedBean bean = new ExtendedBean();
         bean.setHowdy("howdy");

Modified: cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
(original)
+++ cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
Sat Sep 13 09:40:18 2008
@@ -39,9 +39,11 @@
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAny;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
 import org.apache.ws.commons.schema.XmlSchemaObjectTable;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
@@ -311,6 +313,8 @@
         utils.startIf("extraNamespaces");
         utils.appendExpression("' ' + extraNamespaces");
         utils.endBlock();
+        // attributes
+        complexTypeSerializeAttributes(type, "this._");
         utils.appendString(">");
         utils.endBlock();
         code.append(bodyCode);
@@ -324,6 +328,14 @@
         code.append(nameManager.getJavascriptName(name) + ".prototype.serialize = " + functionName
+ ";\n\n");
     }
 
+    private void complexTypeSerializeAttributes(XmlSchemaComplexType type, String string)
{
+        XmlSchemaObjectCollection attributes = type.getAttributes();
+        for (int ax = 0; ax < attributes.getCount(); ax++) {
+            @SuppressWarnings("unused") // work in progress.
+            XmlSchemaAttribute attribute = (XmlSchemaAttribute)attributes.getItem(ax);
+        }
+    }
+
     /**
      * Build the serialization code for a complex type. At the top level, this
      * operates on single items, so it does not pay attention to minOccurs and

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java?rev=694981&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java
(added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java
Sat Sep 13 09:40:18 2008
@@ -0,0 +1,79 @@
+/**
+ * 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.systest.aegis;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.aegis.type.basic.CharacterAsStringType;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.test.TestUtilities;
+import org.junit.Test;
+import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
+
+/**
+ * 
+ */
+public class CharacterSchemaTest extends AbstractDependencyInjectionSpringContextTests {
+    
+    private TestUtilities testUtilities;
+    
+    public CharacterSchemaTest() {
+        testUtilities = new TestUtilities(getClass());
+    }
+    
+    @Override
+    protected String[] getConfigLocations() {
+        return new String[] {"classpath:aegisSportsServiceBeans.xml"};
+    }
+    
+    @Test
+    public void testSchema() throws Exception {
+        testUtilities.setBus((Bus)applicationContext.getBean("cxf"));
+        testUtilities.addDefaultNamespaces();
+        testUtilities.addNamespace("aegis", "http://cxf.apache.org/aegisTypes");
+        Server s = testUtilities.
+            getServerForService(new QName("http://aegis.systest.cxf.apache.org/", 
+                                          "SportsService"));
+        assertNotNull(s);
+        Document wsdl = testUtilities.getWSDLDocument(s); 
+        assertNotNull(wsdl);
+        NodeList typeAttrList = 
+            testUtilities.assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence"
+                                      + "/xsd:element[@name='character']"
+                                      + "/@type", 
+                                      wsdl); 
+        Attr typeAttr = (Attr)typeAttrList.item(0);
+        String typeAttrValue = typeAttr.getValue();
+        // now, this thing is a qname with a :, and we have to work out if it's correct.
+        String[] pieces = typeAttrValue.split(":");
+        assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME.getLocalPart(),
+                     pieces[1]);
+        Node elementNode = typeAttr.getOwnerElement();
+        String url = testUtilities.resolveNamespacePrefix(pieces[0], elementNode);
+        assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME.getNamespaceURI(),
+                     url);
+    }
+}

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java Sat Sep
13 09:40:18 2008
@@ -23,11 +23,15 @@
 
 import javax.jws.WebService;
 
+import org.apache.cxf.aegis.services.SimpleBean;
+
 @WebService(targetNamespace = "http://cxf.apache.org/systest/aegis/sports")
 public interface SportsService {
     Collection<Team> getTeams();
     
     String testForMinOccurs0(String a, Integer b, String c);
     AttributeBean getAttributeBean();
+    // SimpleBean has relevant properties
+    SimpleBean getSimpleBean();
 }
 

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java Sat
Sep 13 09:40:18 2008
@@ -23,6 +23,8 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.cxf.aegis.services.SimpleBean;
+
 /**
  * 
  */
@@ -43,4 +45,8 @@
         return new AttributeBean();
     }
 
+    public SimpleBean getSimpleBean() {
+        return new SimpleBean();
+    }
+
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java?rev=694981&r1=694980&r2=694981&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java Sat Sep
13 09:40:18 2008
@@ -36,9 +36,6 @@
 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;
-import org.apache.cxf.interceptor.LoggingInInterceptor;
-import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.systest.aegis.mtom.fortest.DataHandlerBean;
 import org.apache.cxf.systest.aegis.mtom.fortest.MtomTestImpl;
 import org.apache.cxf.test.TestUtilities;
@@ -75,11 +72,7 @@
             props.put("mtom-enabled", Boolean.TRUE);
         }
         proxyFac.setProperties(props);
-        ServerFactoryBean server = (ServerFactoryBean)applicationContext.getBean("mtom-server");
-        
-        server.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
-        server.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
-        
+
         client = (org.apache.cxf.systest.aegis.mtom.fortest.MtomTest)proxyFac.create();
         impl = (MtomTestImpl)applicationContext.getBean("mtomImpl");
     }

Added: cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml?rev=694981&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml (added)
+++ cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml Sat Sep 13 09:40:18
2008
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:simple="http://cxf.apache.org/simple"
+	xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:cxf="http://cxf.apache.org/core"
+	xsi:schemaLocation="
+http://www.springframework.org/schema/beans 
+http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/simple
+http://cxf.apache.org/schemas/simple.xsd
+http://cxf.apache.org/jaxws
+http://cxf.apache.org/schemas/jaxws.xsd
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
+
+	<import resource="classpath:META-INF/cxf/cxf.xml" />
+	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+	<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+	<import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+	
+	<bean id="sportsImpl"
+		class="org.apache.cxf.systest.aegis.SportsServiceImpl" />
+
+	<simple:server id="sports-server" address="http://localhost:9002/sports"
+		serviceClass="org.apache.cxf.systest.aegis.SportsService">
+		<simple:dataBinding>
+			<bean
+				class="org.apache.cxf.aegis.databinding.AegisDatabinding"/>
+		</simple:dataBinding>
+		<simple:serviceBean>
+			<ref bean="sportsImpl" />
+		</simple:serviceBean>
+	</simple:server>
+</beans>
\ No newline at end of file

Propchange: cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message