You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2010/10/17 04:26:08 UTC
svn commit: r1023402 [9/9] - in /cxf/trunk:
api/src/main/java/org/apache/cxf/databinding/
api/src/main/java/org/apache/cxf/service/model/
common/common/src/main/java/org/apache/cxf/common/xmlschema/
common/common/src/test/java/org/apache/cxf/common/xml...
Modified: cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java (original)
+++ cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java Sun Oct 17 02:26:06 2010
@@ -44,12 +44,12 @@ import org.apache.ws.commons.schema.XmlS
import org.apache.ws.commons.schema.XmlSchemaCollection;
public class WSDLGenerationTester {
-
+
private XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- public WSDLGenerationTester() {
+ public WSDLGenerationTester() {
}
-
+
public void compare(XMLStreamReader orig, XMLStreamReader actual)
throws Exception {
@@ -90,7 +90,7 @@ public class WSDLGenerationTester {
}
private void compareStartElement(XMLStreamReader orig, XMLStreamReader actual)
- throws Exception {
+ throws Exception {
Assert.assertEquals("Start element is not matched", orig.getName(), actual.getName());
int origAttrCount = orig.getAttributeCount();
int actualAttrCount = actual.getAttributeCount();
@@ -102,7 +102,7 @@ public class WSDLGenerationTester {
origAttrCount--;
} else {
Assert.assertEquals("Attribute " + origAttrName + " not found or value not matching",
- orig.getAttributeValue(origAttrName.getNamespaceURI(),
+ orig.getAttributeValue(origAttrName.getNamespaceURI(),
origAttrName.getLocalPart()),
actual.getAttributeValue(origAttrName.getNamespaceURI(),
origAttrName.getLocalPart()));
@@ -114,27 +114,27 @@ public class WSDLGenerationTester {
|| (actualAttrName.getLocalPart().equals("schemaLocation"))) {
//skip this atribute
actualAttrCount--;
- }
- }
+ }
+ }
Assert.assertEquals("Attribute count is not matched for element " + orig.getName(),
origAttrCount,
actualAttrCount);
}
-
+
private void compareEndElement(XMLStreamReader orig, XMLStreamReader actual)
throws Exception {
Assert.assertEquals("End element is not matched", orig.getName(), actual.getName());
}
-
+
private void compareCharacters(XMLStreamReader orig, XMLStreamReader actual)
throws Exception {
Assert.assertEquals("Element Characters not matched", orig.getText(), actual.getText());
- }
+ }
public File writeDefinition(File targetDir, File defnFile) throws Exception {
File bkFile = new File(targetDir, "bk_" + defnFile.getName());
FileWriter writer = new FileWriter(bkFile);
- WSDLFactory factory
+ WSDLFactory factory
= WSDLFactory.newInstance("org.apache.cxf.tools.corba.utils.TestWSDLCorbaFactoryImpl");
WSDLReader reader = factory.newWSDLReader();
reader.setFeature("javax.wsdl.importDocuments", false);
@@ -142,7 +142,7 @@ public class WSDLGenerationTester {
addExtensions(extReg);
reader.setExtensionRegistry(extReg);
Definition wsdlDefn = reader.readWSDL(defnFile.toString());
- WSDLWriter wsdlWriter = factory.newWSDLWriter();
+ WSDLWriter wsdlWriter = factory.newWSDLWriter();
wsdlWriter.writeWSDL(wsdlDefn, writer);
writer.close();
writer = null;
@@ -154,7 +154,7 @@ public class WSDLGenerationTester {
File bkFile = new File(targetDir, "bk_" + schemaFile.getName());
FileWriter writer = new FileWriter(bkFile);
FileReader reader = new FileReader(schemaFile);
- XmlSchema schema = schemaCol.read(reader, null);
+ XmlSchema schema = schemaCol.read(reader);
schema.write(writer);
reader.close();
writer.close();
@@ -170,7 +170,7 @@ public class WSDLGenerationTester {
JAXBExtensionHelper.addExtensions(extReg, Definition.class, TypeMappingType.class);
JAXBExtensionHelper.addExtensions(extReg, Port.class,
org.apache.cxf.binding.corba.wsdl.AddressType.class);
-
+
extReg.mapExtensionTypes(Binding.class, CorbaConstants.NE_CORBA_BINDING, BindingType.class);
extReg.mapExtensionTypes(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION,
org.apache.cxf.binding.corba.wsdl.OperationType.class);
@@ -179,5 +179,5 @@ public class WSDLGenerationTester {
extReg.mapExtensionTypes(Port.class, CorbaConstants.NE_CORBA_ADDRESS,
org.apache.cxf.binding.corba.wsdl.AddressType.class);
}
-
+
}
Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java?rev=1023402&r1=1023401&r2=1023402&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java (original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java Sun Oct 17 02:26:06 2010
@@ -24,10 +24,8 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-
import javax.xml.namespace.QName;
import org.w3c.dom.Attr;
@@ -52,8 +50,8 @@ import org.apache.ws.commons.schema.XmlS
import org.apache.ws.commons.schema.XmlSchemaComplexType;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaForm;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
public final class ProcessorUtil {
private static final String KEYWORDS_PREFIX = "_";
@@ -72,7 +70,7 @@ public final class ProcessorUtil {
public static String resolvePartType(MessagePartInfo part) {
return NameUtil.mangleNameToClassName(getPartType(part));
}
-
+
public static String getType(MessagePartInfo part, ToolContext context, boolean fullname) {
String type = "";
DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
@@ -91,7 +89,7 @@ public final class ProcessorUtil {
DataBindingProfile dataBinding = context.get(DataBindingProfile.class);
if (part.isElement()) {
return dataBinding.createDefaultValueWriter(getElementName(part), true);
- }
+ }
return dataBinding.createDefaultValueWriter(part.getTypeQName(), false);
}
public static DefaultValueWriter getDefaultValueWriterForWrappedElement(MessagePartInfo part,
@@ -147,20 +145,20 @@ public final class ProcessorUtil {
if (name == null) {
String namespace = resolvePartNamespace(part);
if ("http://www.w3.org/2005/08/addressing".equals(namespace)) {
- //The ws-addressing stuff isn't mapped in jaxb as jax-ws specifies they
+ //The ws-addressing stuff isn't mapped in jaxb as jax-ws specifies they
//need to be mapped differently
String pn = part.getConcreteName().getLocalPart();
if ("EndpointReference".equals(pn)
|| "ReplyTo".equals(pn)
|| "From".equals(pn)
|| "FaultTo".equals(pn)) {
-
+
name = "javax.xml.ws.wsaddressing.W3CEndpointReference";
}
}
-
+
}
- return name;
+ return name;
}
public static String resolvePartNamespace(MessagePartInfo part) {
@@ -192,7 +190,7 @@ public final class ProcessorUtil {
} else {
return resolvePath(new File(location).getAbsolutePath());
}
-
+
}
public static URL getWSDLURL(String location) throws Exception {
@@ -226,26 +224,26 @@ public final class ProcessorUtil {
QName xmlTypeName = getElementName(part);
// if this flag is true , mapping to java Type first;
- // if not found , findd the primitive type : int ,long
+ // if not found , findd the primitive type : int ,long
// if not found, find in the generated class
-
-
+
+
if (!primitiveType && dataBinding != null) {
jtype = dataBinding.getType(xmlTypeName, true);
- }
-
+ }
+
if (!primitiveType && dataBinding == null) {
Class holderClass = JAXBUtils.holderClass(xmlTypeName.getLocalPart());
jtype = holderClass == null ? null : holderClass.getName();
if (jtype == null) {
jtype = JAXBUtils.builtInTypeToJavaType(xmlTypeName.getLocalPart());
- }
+ }
}
-
+
if (primitiveType) {
jtype = JAXBUtils.builtInTypeToJavaType(xmlTypeName.getLocalPart());
}
-
+
String namespace = xmlTypeName.getNamespaceURI();
String type = resolvePartType(part, context, true);
String userPackage = context.mapPackageName(namespace);
@@ -260,14 +258,14 @@ public final class ProcessorUtil {
jtype = resolvePartType(part, context, true);
} else {
jtype = parsePackageName(namespace, userPackage) + "." + type;
- }
- }
-
-
+ }
+ }
+
+
return jtype;
}
-
+
public static String getFileOrURLName(String fileOrURL) {
try {
@@ -309,14 +307,14 @@ public final class ProcessorUtil {
return name + "_handler";
}
-
+
public static Node cloneNode(Document document, Node node, boolean deep) throws DOMException {
if (document == null || node == null) {
return null;
}
int type = node.getNodeType();
-
+
if (node.getOwnerDocument() == document) {
return node.cloneNode(deep);
}
@@ -335,15 +333,15 @@ public final class ProcessorUtil {
clone = document.createElementNS(node.getNamespaceURI(), node.getNodeName());
NamedNodeMap attributes = node.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
- Attr attr = (Attr)attributes.item(i);
- Attr attrnew =
- ((Element)clone).getOwnerDocument().createAttributeNS(attr.getNamespaceURI(),
+ Attr attr = (Attr)attributes.item(i);
+ Attr attrnew =
+ ((Element)clone).getOwnerDocument().createAttributeNS(attr.getNamespaceURI(),
attr.getNodeName());
attrnew.setValue(attr.getNodeValue());
- ((Element)clone).setAttributeNodeNS(attrnew);
+ ((Element)clone).setAttributeNodeNS(attrnew);
}
break;
-
+
case Node.TEXT_NODE:
clone = document.createTextNode(node.getNodeValue());
break;
@@ -373,43 +371,42 @@ public final class ProcessorUtil {
public static List<WrapperElement> getWrappedElement(ToolContext context, QName partElement) {
List<WrapperElement> qnames = new ArrayList<WrapperElement>();
-
+
ServiceInfo serviceInfo = (ServiceInfo)context.get(ServiceInfo.class);
SchemaCollection schema = serviceInfo.getXmlSchemaCollection();
-
+
XmlSchemaElement elementByName = schema.getElementByQName(partElement);
-
+
XmlSchemaComplexType type = (XmlSchemaComplexType)elementByName.getSchemaType();
XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
-
- if (seq != null) {
- XmlSchemaObjectCollection items = seq.getItems();
+ if (seq != null) {
- Iterator ite = items.getIterator();
+ List<XmlSchemaSequenceMember> items = seq.getItems();
- while (ite.hasNext()) {
- XmlSchemaElement subElement = (XmlSchemaElement)ite.next();
+ for (XmlSchemaSequenceMember seqMember : items) {
+ XmlSchemaElement subElement = (XmlSchemaElement)seqMember;
if (subElement.getQName() != null) {
qnames.add(new WrapperElement(subElement.getQName(), subElement.getSchemaTypeName()));
} else {
- qnames.add(new WrapperElement(subElement.getRefName(), subElement.getSchemaTypeName()));
+ qnames.add(new WrapperElement(subElement.getRef().getTargetQName(),
+ subElement.getSchemaTypeName()));
}
}
}
return qnames;
}
-
+
public static boolean isSchemaFormQualified(ToolContext context, QName partElement) {
ServiceInfo serviceInfo = (ServiceInfo)context.get(ServiceInfo.class);
SchemaCollection schemaCol = serviceInfo.getXmlSchemaCollection();
XmlSchema schema = schemaCol.getSchemaForElement(partElement);
if (schema != null) {
- return schema.getElementFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED);
+ return schema.getElementFormDefault() == XmlSchemaForm.QUALIFIED;
}
return false;
-
+
}
}