You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/09/15 17:09:15 UTC
svn commit: r695492 - in /cxf/branches/2.1.x-fixes: ./
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/...
Author: dkulp
Date: Mon Sep 15 08:09:14 2008
New Revision: 695492
URL: http://svn.apache.org/viewvc?rev=695492&view=rev
Log:
Merged revisions 694981 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r694981 | bimargulies | 2008-09-13 12:40:18 -0400 (Sat, 13 Sep 2008) | 3 lines
Replace use of SOAP-encoding for char with a specialization of integer.
........
Added:
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java
- copied unchanged from r694981, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/CharacterSchemaTest.java
cxf/branches/2.1.x-fixes/systests/src/test/resources/aegisSportsServiceBeans.xml
- copied unchanged from r694981, cxf/trunk/systests/src/test/resources/aegisSportsServiceBeans.xml
Modified:
cxf/branches/2.1.x-fixes/ (props changed)
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java
cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java
cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java
Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep 15 08:09:14 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981
Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java Mon Sep 15 08:09:14 2008
@@ -117,4 +117,9 @@
public void setProperties(Map<String, Object> properties) {
this.putAll(properties);
}
+
+ @Override
+ public String toString() {
+ return "[ServiceImpl " + getName() + "]";
+ }
}
Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java Mon Sep 15 08:09:14 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<T> 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<T> 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/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java Mon Sep 15 08:09:14 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/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java Mon Sep 15 08:09:14 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/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/Type.java Mon Sep 15 08:09:14 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/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java Mon Sep 15 08:09:14 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/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java Mon Sep 15 08:09:14 2008
@@ -29,6 +29,7 @@
private String howdy;
private int[] numbers;
+ private char primitiveCharacter;
public int[] getNumbers() {
return numbers;
@@ -63,4 +64,12 @@
public void setHowdy(String howdy) {
this.howdy = howdy;
}
+
+ public char getPrimitiveChar() {
+ return primitiveCharacter;
+ }
+
+ public void setPrimitiveChar(char pchar) {
+ this.primitiveCharacter = pchar;
+ }
}
Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java Mon Sep 15 08:09:14 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(4, pds.length);
+ assertEquals(6, pds.length);
ExtendedBean bean = new ExtendedBean();
bean.setHowdy("howdy");
Modified: cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java (original)
+++ cxf/branches/2.1.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java Mon Sep 15 08:09:14 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
Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsService.java Mon Sep 15 08:09:14 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/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/SportsServiceImpl.java Mon Sep 15 08:09:14 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/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java?rev=695492&r1=695491&r2=695492&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/aegis/mtom/MtomTest.java Mon Sep 15 08:09:14 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");
}