summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.3.1/modules
diff options
context:
space:
mode:
authornash <nash@13f79535-47bb-0310-9956-ffa450edef68>2008-08-14 13:52:14 +0000
committernash <nash@13f79535-47bb-0310-9956-ffa450edef68>2008-08-14 13:52:14 +0000
commitd88e15805f4a4145b4975e166561340c134c9d24 (patch)
treeede9b0efdc4a58d2761fc2a67e3fa15eaa4567da /branches/sca-java-1.3.1/modules
parent5c6c6b427b6a2b0fbb89831576d9e8cd89e545bc (diff)
Fix TUSCANY-2531
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685897 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3.1/modules')
-rw-r--r--branches/sca-java-1.3.1/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java6
-rw-r--r--branches/sca-java-1.3.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java29
-rw-r--r--branches/sca-java-1.3.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java35
3 files changed, 63 insertions, 7 deletions
diff --git a/branches/sca-java-1.3.1/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/branches/sca-java-1.3.1/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
index 263b96d20f..532c0848ec 100644
--- a/branches/sca-java-1.3.1/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
+++ b/branches/sca-java-1.3.1/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
@@ -536,10 +536,12 @@ public class Axis2ServiceProvider {
if (obj instanceof XmlSchemaExternal) {
XmlSchemaExternal extSchema = (XmlSchemaExternal)obj;
String location = extSchema.getSchemaLocation();
- if (location.indexOf(":/") < 0 & location.indexOf("?xsd=") < 0) {
+ if (location.length() > 0 && location.indexOf(":/") < 0 && location.indexOf("?xsd=") < 0) {
extSchema.setSchemaLocation(name + "?xsd=" + location);
}
- updateSchemaRefs(extSchema.getSchema(), name);
+ if (extSchema.getSchema() != null) {
+ updateSchemaRefs(extSchema.getSchema(), name);
+ }
}
}
}
diff --git a/branches/sca-java-1.3.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/branches/sca-java-1.3.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
index 2e8e34853e..be87ec611b 100644
--- a/branches/sca-java-1.3.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
+++ b/branches/sca-java-1.3.1/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
@@ -76,6 +76,8 @@ import org.apache.ws.commons.schema.XmlSchemaException;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* @version $Rev: 670103 $ $Date: 2008-06-21 01:35:00 +0100 (Sat, 21 Jun 2008) $
@@ -325,7 +327,10 @@ public class Interface2WSDLGenerator {
}
QName typeName = element.getType().getQName();
String nsURI = typeName.getNamespaceURI();
- if ("".equals(nsURI) || targetNS.equals(nsURI)) {
+ if ("".equals(nsURI)) {
+ xsElement.setAttribute("type", typeName.getLocalPart());
+ addSchemaImport(schema, "", schemaDoc);
+ } else if (targetNS.equals(nsURI)) {
xsElement.setAttribute("type", typeName.getLocalPart());
} else if (SCHEMA_NS.equals(nsURI)) {
xsElement.setAttribute("type", "xs:" + typeName.getLocalPart());
@@ -336,6 +341,7 @@ public class Interface2WSDLGenerator {
prefix = "ns" + i++;
prefixMap.put(nsURI, prefix);
schema.setAttributeNS(XMLNS_NS, "xmlns:" + prefix, nsURI);
+ addSchemaImport(schema, nsURI, schemaDoc);
}
xsElement.setAttribute("type", prefix + ":" + typeName.getLocalPart());
}
@@ -354,7 +360,26 @@ public class Interface2WSDLGenerator {
return definition;
}
-
+
+ private static void addSchemaImport(Element schema, String nsURI, Document schemaDoc) {
+ Element imp = schemaDoc.createElementNS(SCHEMA_NS, "xs:import");
+ if (!"".equals(nsURI)) {
+ imp.setAttribute("namespace", nsURI);
+ }
+ NodeList childNodes = schema.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node childNode = childNodes.item(i);
+ if (childNode instanceof Element) {
+ schema.insertBefore(imp, childNode);
+ imp = null;
+ break;
+ }
+ }
+ if (imp != null) {
+ schema.appendChild(imp);
+ }
+ }
+
private void addSchemaExtension(XSDefinition xsDef,
XmlSchemaCollection schemaCollection,
WSDLDefinition wsdlDefinition,
diff --git a/branches/sca-java-1.3.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java b/branches/sca-java-1.3.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
index 8c7ab2f8cd..573e636884 100644
--- a/branches/sca-java-1.3.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
+++ b/branches/sca-java-1.3.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.databinding.jaxb;
-import java.beans.Introspector;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
@@ -74,13 +73,43 @@ public class JAXBTypeHelper implements XMLTypeHelper {
xmlType = ((XMLType)logical).getTypeName();
}
if (xmlType == null) {
- xmlType =
- new QName(JavaXMLMapper.getNamespace(javaType), Introspector.decapitalize(javaType.getSimpleName()));
+ xmlType = new QName(jaxbRIDecapitalize(javaType.getSimpleName()));
}
return new TypeInfo(xmlType, false, null);
}
}
+ /**
+ * The JAXB RI doesn't implement the decapitalization algorithm in the
+ * JAXB spec. See Sun bug 6505643 for details. This means that we need
+ * to mimic the incorrect algorithm for references from wrapper schemas.
+ */
+ private String jaxbRIDecapitalize(String name) {
+ // find first lower case char in name
+ int lower = name.length();
+ for (int i = 0; i < name.length(); i++) {
+ if (Character.isLowerCase(name.charAt(i))) {
+ lower = i;
+ break;
+ }
+ }
+
+ int decap;
+ if (name.length() == 0) {
+ decap = 0; // empty string: nothing to do
+ } else if (lower == 0) {
+ decap = 0; // first char is lower case: nothing to do
+ } else if (lower == 1) {
+ decap = 1; // one upper followed by lower: decapitalize 1 char
+ } else if (lower < name.length()) {
+ decap = lower - 1; // n uppers followed by at least one lower: decapitalize n-1 chars
+ } else {
+ decap = name.length(); // all upper case: decapitalize all chars
+ }
+
+ return name.substring(0, decap).toLowerCase() + name.substring(decap);
+ }
+
/*
public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver) {
List<XSDefinition> definitions = new ArrayList<XSDefinition>();