Author: dkulp
Date: Fri Nov 9 14:59:41 2007
New Revision: 593684
URL: http://svn.apache.org/viewvc?rev=593684&view=rev
Log:
Merged revisions 593624 via svnmerge from
https://svn.apache.org/repos/asf/incubator/cxf/trunk
........
r593624 | dkulp | 2007-11-09 14:03:17 -0500 (Fri, 09 Nov 2007) | 4 lines
[CXF-1195] Allow dv plugin to do default values for enums
Make sure more MessagePartInfo objects have XmlSchema objects properly set
(work in progress)
Fix issue that without asm, wrapper types with collections aren't properly
marshalled
........
Modified:
incubator/cxf/branches/2.0.x-fixes/ (props changed)
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/java/org/apache/cxf/xjc/dv/DefaultValueTest.java
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/resources/schemas/configuration/foo.xsd
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/strategy/ConventionStrategy.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java
incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/java/org/apache/cxf/xjc/dv/DefaultValueTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/java/org/apache/cxf/xjc/dv/DefaultValueTest.java?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/java/org/apache/cxf/xjc/dv/DefaultValueTest.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/java/org/apache/cxf/xjc/dv/DefaultValueTest.java
Fri Nov 9 14:59:41 2007
@@ -149,6 +149,8 @@
}
private void assertDefaultElementValues(Foo foo) {
+ assertEquals("Unexpected value for element driving",
+ "LeftTurn", foo.getDriving().value());
assertEquals("Unexpected value for element stringElem",
"hello", foo.getStringElem());
assertTrue("Unexpected value for element booleanElem",
Modified:
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/resources/schemas/configuration/foo.xsd
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/resources/schemas/configuration/foo.xsd?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/resources/schemas/configuration/foo.xsd
(original)
+++
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv-test/src/test/resources/schemas/configuration/foo.xsd
Fri Nov 9 14:59:41 2007
@@ -32,9 +32,18 @@
<xs:minExclusive value="0"/>
</xs:restriction>
</xs:simpleType>
+
+ <xs:simpleType name="drivingDecision">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="RightTurn"/>
+ <xs:enumeration value="LeftTurn"/>
+ <xs:enumeration value="U-Turn"/>
+ </xs:restriction>
+ </xs:simpleType>
<xs:complexType name="foo">
<xs:sequence>
+ <xs:element name="driving" type="tns:drivingDecision"
default="LeftTurn" minOccurs="0"></xs:element>
<xs:element name="stringElem" type="xs:string" default="hello"
minOccurs="0"></xs:element>
<xs:element name="booleanElem" type="xs:boolean" default="true"
minOccurs="0"></xs:element>
<xs:element name="integerElem" type="xs:integer" default="11"
minOccurs="0"></xs:element>
Modified:
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/xjc/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/common/xjc/dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
Fri Nov 9 14:59:41 2007
@@ -29,6 +29,7 @@
import org.xml.sax.ErrorHandler;
+import com.sun.codemodel.ClassType;
import com.sun.codemodel.JConditional;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JDocComment;
@@ -185,7 +186,12 @@
.arg(qn.getPrefix());
} else if ("javax.xml.datatype.Duration".equals(typeName)) {
dv =
outline.getCodeModel().ref(org.apache.cxf.jaxb.DatatypeFactory.class)
- .staticInvoke("createDuration").arg(defaultValue);
+ .staticInvoke("createDuration").arg(defaultValue);
+ } else if (type instanceof JDefinedClass) {
+ JDefinedClass cls = (JDefinedClass)type;
+ if (cls.getClassType() == ClassType.ENUM) {
+ dv = cls.staticInvoke("fromValue").arg(defaultValue);
+ }
}
// TODO: GregorianCalendar, ...
return dv;
Modified:
incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
Fri Nov 9 14:59:41 2007
@@ -218,6 +218,10 @@
if (schemaAnnotation instanceof XmlSchemaElement) {
element = (XmlSchemaElement)schemaAnnotation;
qname = element.getQName();
+ if (element.getSchemaType() instanceof XmlSchemaSimpleType) {
+ throw new Fault(new Message("SIMPLE_TYPE", BUNDLE));
+ }
+
cplxType = (XmlSchemaComplexType)element.getSchemaType();
unQualified = findSchemaUnQualified(schemas,
element.getSchemaTypeName());
if (cplxType == null) {
Modified:
incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/strategy/ConventionStrategy.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/strategy/ConventionStrategy.java?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/strategy/ConventionStrategy.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/strategy/ConventionStrategy.java
Fri Nov 9 14:59:41 2007
@@ -21,10 +21,13 @@
import java.lang.reflect.Method;
import java.util.logging.Logger;
+import javax.xml.namespace.QName;
+
import org.apache.cxf.binding.http.URIMapper;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.ws.commons.schema.XmlSchemaElement;
import static org.apache.cxf.binding.http.HttpConstants.DELETE;
import static org.apache.cxf.binding.http.HttpConstants.GET;
@@ -132,8 +135,13 @@
private boolean isXSDPrimitive(MessagePartInfo part) {
String xsdNs = "http://www.w3.org/2001/XMLSchema";
- if (!part.isElement()
- && part.getTypeQName().getNamespaceURI().equals(xsdNs)) {
+ QName tn = null;
+ if (part.isElement()) {
+ tn = ((XmlSchemaElement)part.getXmlSchema()).getSchemaTypeName();
+ } else {
+ tn = part.getTypeQName();
+ }
+ if (tn != null && tn.getNamespaceURI().equals(xsdNs)) {
return true;
}
Modified:
incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Fri Nov 9 14:59:41 2007
@@ -150,6 +150,8 @@
QName typeName = getTypeName(beanInfo);
createBridgeXsElement(part, qn, typeName);
+ } else if (part.getXmlSchema() == null) {
+ part.setXmlSchema(el);
}
}
}
Modified:
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java
Fri Nov 9 14:59:41 2007
@@ -268,7 +268,11 @@
Object ret = wrapperType.newInstance();
for (int x = 0; x < setMethods.length; x++) {
- if (setMethods[x] == null && fields[x] == null) {
+ if (getMethods[x] == null
+ && setMethods[x] == null
+ && fields[x] == null) {
+ //this part is a header or something
+ //that is not part of the wrapper.
continue;
}
Object o = lst.get(x);
Modified:
incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Fri Nov 9 14:59:41 2007
@@ -332,6 +332,61 @@
} else {
buildServiceFromClass();
}
+ //assert validateServiceModel();
+ }
+
+ public boolean validateServiceModel() {
+ for (ServiceInfo si : getService().getServiceInfos()) {
+ for (OperationInfo opInfo : si.getInterface().getOperations()) {
+ for (MessagePartInfo mpi :
opInfo.getInput().getMessageParts()) {
+ assert mpi.getXmlSchema() != null;
+ if (mpi.isElement()) {
+ assert mpi.getXmlSchema() instanceof XmlSchemaElement;
+ } else {
+ assert !(mpi.getXmlSchema() instanceof
XmlSchemaElement);
+ }
+ }
+ for (MessagePartInfo mpi :
opInfo.getOutput().getMessageParts()) {
+ assert mpi.getXmlSchema() != null;
+ if (mpi.isElement()) {
+ assert mpi.getXmlSchema() instanceof XmlSchemaElement;
+ } else {
+ assert !(mpi.getXmlSchema() instanceof
XmlSchemaElement);
+ }
+ }
+ if (opInfo.isUnwrappedCapable()) {
+ opInfo = opInfo.getUnwrappedOperation();
+ for (MessagePartInfo mpi :
opInfo.getInput().getMessageParts()) {
+ assert mpi.getXmlSchema() != null;
+ if (mpi.isElement()) {
+ assert mpi.getXmlSchema() instanceof
XmlSchemaElement;
+ } else {
+ assert !(mpi.getXmlSchema() instanceof
XmlSchemaElement);
+ }
+ }
+ for (MessagePartInfo mpi :
opInfo.getOutput().getMessageParts()) {
+ assert mpi.getXmlSchema() != null;
+ if (mpi.isElement()) {
+ assert mpi.getXmlSchema() instanceof
XmlSchemaElement;
+ } else {
+ assert !(mpi.getXmlSchema() instanceof
XmlSchemaElement);
+ }
+ }
+ }
+ if (opInfo.hasFaults()) {
+ //check to make sure the faults are elements
+ for (FaultInfo fault : opInfo.getFaults()) {
+ MessagePartInfo mpi = fault.getMessagePart(0);
+ assert mpi != null;
+ assert mpi.getXmlSchema() != null;
+ assert mpi.isElement();
+ assert mpi.getXmlSchema() instanceof XmlSchemaElement;
+ }
+ }
+
+ }
+ }
+ return true;
}
public boolean isPopulateFromClass() {
@@ -696,12 +751,15 @@
addImport(schema,
oldEl.getSchemaTypeName().getNamespaceURI());
}
}
+ mpi.setElement(true);
mpi.setXmlSchema(el);
mpi.setElementQName(qname);
mpi.setConcreteName(qname);
continue;
} else {
el.setSchemaTypeName(mpi.getTypeQName());
+ mpi.setXmlSchema(el);
+ mpi.setConcreteName(qname);
addImport(schema, mpi.getTypeQName().getNamespaceURI());
}
@@ -800,11 +858,18 @@
el.setSchemaType((XmlSchemaType)mpi.getXmlSchema());
if
(schema.getElementFormDefault().getValue().equals(XmlSchemaForm.UNQUALIFIED)) {
mpi.setConcreteName(new QName(null,
mpi.getName().getLocalPart()));
+ } else {
+ mpi.setConcreteName(mpi.getName());
}
}
if (!Boolean.TRUE.equals(mpi.getProperty(HEADER))) {
- if (!mpi.isElement()) {
- mpi.setXmlSchema(el);
+ boolean wasType = !mpi.isElement();
+ if (wasType) {
+ QName concreteName = mpi.getConcreteName();
+ mpi.setXmlSchema(el);
+ mpi.setElement(true);
+ mpi.setElementQName(el.getQName());
+ mpi.setConcreteName(concreteName);
}
if (mpi.getTypeClass() != null && mpi.getTypeClass().isArray()
&&
!Byte.TYPE.equals(mpi.getTypeClass().getComponentType())) {
@@ -825,13 +890,14 @@
} else if
(Collection.class.isAssignableFrom(mpi.getTypeClass())
&& mpi.getTypeClass().isInterface()) {
Type type = (Type)mpi.getProperty(GENERIC_TYPE);
+
if (!(type instanceof java.lang.reflect.ParameterizedType)
- && mpi.getTypeQName() == null) {
+ && el.getSchemaTypeName() == null
+ && el.getSchemaType() == null) {
el.setMinOccurs(0);
el.setMaxOccurs(Long.MAX_VALUE);
el.setSchemaTypeName(Constants.XSD_ANYTYPE);
}
-
} else {
el.setMaxOccurs(1);
if (mpi.getTypeClass() != null &&
!mpi.getTypeClass().isPrimitive()) {
Modified:
incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=593684&r1=593683&r2=593684&view=diff
==============================================================================
---
incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++
incubator/cxf/branches/2.0.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Fri Nov 9 14:59:41 2007
@@ -404,7 +404,8 @@
//Test for cxf774
public void testList() throws Exception {
env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() +
"/list_test.wsdl");
- env.put(ToolConstants.CFG_CLASSNAME,
"org.apache.cxf.tools.fortest.cxf774.ListTestImpl");
+ env.put(ToolConstants.CFG_CLASSNAME,
+
org.apache.cxf.tools.fortest.cxf774.ListTestImpl.class.getName());
env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
try {
processor.setEnvironment(env);