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 2007/11/08 19:30:40 UTC
svn commit: r593243 - in /incubator/cxf/trunk:
common/common/src/main/java/org/apache/cxf/staxutils/ parent/ rt/
rt/databinding/xmlbeans/ rt/databinding/xmlbeans/src/
rt/databinding/xmlbeans/src/main/ rt/databinding/xmlbeans/src/main/java/
rt/databindi...
Author: dkulp
Date: Thu Nov 8 10:30:36 2007
New Revision: 593243
URL: http://svn.apache.org/viewvc?rev=593243&view=rev
Log:
Start of xmlbeans databinding (doesn't handle much yet)
Fix some issues with not generating imports into schemas
Added:
incubator/cxf/trunk/rt/databinding/xmlbeans/ (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/pom.xml (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/AbstractXmlBeansTest.java (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/BasicTest.java (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/TestService.java (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml (with props)
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/
incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/XmlBeanTest.xsd (with props)
Modified:
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
incubator/cxf/trunk/parent/pom.xml
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
incubator/cxf/trunk/rt/pom.xml
Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=593243&r1=593242&r2=593243&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Thu Nov 8 10:30:36 2007
@@ -254,6 +254,10 @@
* @throws XMLStreamException
*/
public static void copy(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+ copy(reader, writer, false);
+ }
+ public static void copy(XMLStreamReader reader, XMLStreamWriter writer,
+ boolean fragment) throws XMLStreamException {
// number of elements read in
int read = 0;
int event = reader.getEventType();
@@ -267,7 +271,7 @@
case XMLStreamConstants.END_ELEMENT:
writer.writeEndElement();
read--;
- if (read <= 0) {
+ if (read <= 0 && !fragment) {
return;
}
break;
Modified: incubator/cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/parent/pom.xml?rev=593243&r1=593242&r2=593243&view=diff
==============================================================================
--- incubator/cxf/trunk/parent/pom.xml (original)
+++ incubator/cxf/trunk/parent/pom.xml Thu Nov 8 10:30:36 2007
@@ -46,7 +46,7 @@
<jaxb.version>2.1</jaxb.version>
<jaxb.impl.version>2.1.4</jaxb.impl.version>
<jaxb.xjc.version>2.1.4</jaxb.xjc.version>
- <jaxws.version>2.1</jaxws.version>
+ <jaxws.version>2.1-1</jaxws.version>
<jetty.version>6.1.5</jetty.version>
<saaj.version>1.3</saaj.version>
<saaj.impl.version>1.3</saaj.impl.version>
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 8 10:30:36 2007
@@ -0,0 +1,10 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+
+
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/pom.xml?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/pom.xml (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/pom.xml Thu Nov 8 10:30:36 2007
@@ -0,0 +1,155 @@
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-rt-databinding-xmlbeans</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache CXF Runtime XmlBeans DataBinding</name>
+ <url>http://cwiki.apache.org/CXF</url>
+
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>2.1-incubator-SNAPSHOT</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-tools-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-testutils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
+ <version>2.3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </dependency>
+
+
+
+
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-local</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-testsupport</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>xmlbeans-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>xmlbeans-test</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <schemaDirectory>src/test/xsd</schemaDirectory>
+ <sourceGenerationDirectory>${project.build.directory}/generated/src/test/java</sourceGenerationDirectory>
+ <classGenerationDirectory>${project.build.directory}/generated/src/test/resources</classGenerationDirectory>
+ <!--noJavac>true</noJavac-->
+ <javaSource>1.5</javaSource>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java Thu Nov 8 10:30:36 2007
@@ -0,0 +1,80 @@
+/**
+ * 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.xmlbeans;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.xmlbeans.XmlOptions;
+
+
+public class DataReaderImpl implements DataReader<XMLStreamReader> {
+ private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
+
+ public DataReaderImpl() {
+ }
+
+ public Object read(XMLStreamReader input) {
+ return read(null, input);
+ }
+
+ public Object read(MessagePartInfo part, XMLStreamReader reader) {
+ Class<?> cls[] = part.getTypeClass().getDeclaredClasses();
+ for (Class<?> c : cls) {
+ if ("Factory".equals(c.getSimpleName())) {
+ try {
+ XmlOptions options = new XmlOptions();
+ options.setLoadReplaceDocumentElement(null);
+ Method meth = c.getMethod("parse", XMLStreamReader.class, XmlOptions.class);
+ return meth.invoke(null, reader, options);
+ } catch (Exception e) {
+ throw new Fault(new Message("UNMARSHAL_ERROR", LOG, part.getTypeClass()), e);
+ }
+ }
+ }
+ return null;
+ }
+
+ public Object read(QName name, XMLStreamReader input, Class type) {
+ return null;
+ }
+
+
+ public void setAttachments(Collection<Attachment> attachments) {
+ }
+
+ public void setProperty(String prop, Object value) {
+ }
+
+ public void setSchema(Schema s) {
+ }
+
+}
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java Thu Nov 8 10:30:36 2007
@@ -0,0 +1,95 @@
+/**
+ * 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.xmlbeans;
+
+
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.validation.Schema;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.XmlTokenSource;
+
+public class DataWriterImpl implements DataWriter<XMLStreamWriter> {
+ private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
+
+ public DataWriterImpl() {
+ }
+
+ public void write(Object obj, XMLStreamWriter output) {
+ write(obj, null, output);
+ }
+
+ public void write(Object obj, MessagePartInfo part, XMLStreamWriter output) {
+ try {
+ if (obj != null
+ || !(part.getXmlSchema() instanceof XmlSchemaElement)) {
+ XmlTokenSource source = (XmlTokenSource)obj;
+ XmlOptions options = new XmlOptions();
+ XMLStreamReader reader = source.newCursor().newXMLStreamReader(options);
+ output.writeStartElement(part.getConcreteName().getNamespaceURI(),
+ part.getConcreteName().getLocalPart());
+ StaxUtils.copy(reader, output, true);
+ output.writeEndElement();
+ } else if (obj == null && needToRender(obj, part)) {
+ output.writeStartElement(part.getConcreteName().getNamespaceURI(),
+ part.getConcreteName().getLocalPart());
+ output.writeEndElement();
+ }
+ } catch (XMLStreamException e) {
+ throw new Fault(new Message("MARSHAL_ERROR", LOG, obj), e);
+ }
+ }
+
+ private boolean needToRender(Object obj, MessagePartInfo part) {
+ if (part != null && part.getXmlSchema() instanceof XmlSchemaElement) {
+ XmlSchemaElement element = (XmlSchemaElement)part.getXmlSchema();
+ return element.isNillable() && element.getMinOccurs() > 0;
+ }
+ return false;
+ }
+
+ public void setAttachments(Collection<Attachment> attachments) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setProperty(String key, Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSchema(Schema s) {
+ // TODO Auto-generated method stub
+
+ }
+}
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties Thu Nov 8 10:30:36 2007
@@ -0,0 +1,22 @@
+#
+#
+# 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.
+#
+#
+MARSHAL_ERROR = Marshalling Error: {0}
+UNMARSHAL_ERROR = Unmarshalling Error: {0}
\ No newline at end of file
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java Thu Nov 8 10:30:36 2007
@@ -0,0 +1,109 @@
+/**
+ * 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.xmlbeans;
+
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.databinding.source.AbstractDataBinding;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+
+/**
+ *
+ */
+public class XmlBeansDataBinding extends AbstractDataBinding implements DataBinding {
+ private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
+
+ private static final Class<?> SUPPORTED_READER_FORMATS[] = new Class<?>[] {XMLStreamReader.class};
+ private static final Class<?> SUPPORTED_WRITER_FORMATS[] = new Class<?>[] {XMLStreamWriter.class};
+
+
+ @SuppressWarnings("unchecked")
+ public <T> DataWriter<T> createWriter(Class<T> c) {
+ if (c == XMLStreamWriter.class) {
+ return (DataWriter<T>)new DataWriterImpl();
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DataReader<T> createReader(Class<T> c) {
+ DataReader<T> dr = null;
+ if (c == XMLStreamReader.class) {
+ dr = (DataReader<T>)new DataReaderImpl();
+ }
+ return dr;
+ }
+
+
+ /**
+ * XmlBeans has no declared namespace prefixes.
+ * {@inheritDoc}
+ */
+ public Map<String, String> getDeclaredNamespaceMappings() {
+ return null;
+ }
+
+ public Class<?>[] getSupportedReaderFormats() {
+ return SUPPORTED_READER_FORMATS;
+ }
+
+ public Class<?>[] getSupportedWriterFormats() {
+ return SUPPORTED_WRITER_FORMATS;
+ }
+
+ public void initialize(Service service) {
+ if (LOG.isLoggable(Level.FINER)) {
+ LOG.log(Level.FINER, "Creating XmlBeansDatabinding for " + service.getName());
+ }
+ for (ServiceInfo serviceInfo : service.getServiceInfos()) {
+ XmlSchemaCollection col = serviceInfo.getXmlSchemaCollection();
+
+ if (col.getXmlSchemas().length > 1) {
+ // someone has already filled in the types
+ continue;
+ }
+
+ XmlBeansSchemaInitializer schemaInit
+ = new XmlBeansSchemaInitializer(serviceInfo, col, this);
+ schemaInit.walk();
+ }
+ }
+
+ public XmlSchema addSchemaDocument(ServiceInfo serviceInfo,
+ XmlSchemaCollection col,
+ Document d,
+ String systemId) {
+ return super.addSchemaDocument(serviceInfo, col, d, systemId);
+ }
+}
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java Thu Nov 8 10:30:36 2007
@@ -0,0 +1,145 @@
+/**
+ * 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.xmlbeans;
+
+
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.service.ServiceModelVisitor;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.SchemaTypeSystem;
+
+/**
+ * Walks the service model and sets up the element/type names.
+ */
+class XmlBeansSchemaInitializer extends ServiceModelVisitor {
+ private static final Logger LOG = LogUtils.getLogger(XmlBeansSchemaInitializer.class);
+ private XmlSchemaCollection schemas;
+ private XmlBeansDataBinding dataBinding;
+ private Map<String, XmlSchema> schemaMap
+ = new HashMap<String, XmlSchema>();
+
+ public XmlBeansSchemaInitializer(ServiceInfo serviceInfo,
+ XmlSchemaCollection col,
+ XmlBeansDataBinding db) {
+ super(serviceInfo);
+ schemas = col;
+ dataBinding = db;
+ }
+
+
+ XmlSchema getSchema(SchemaTypeSystem sts, String file) {
+ if (schemaMap.containsKey(file)) {
+ return schemaMap.get(file);
+ }
+ InputStream ins = sts.getSourceAsStream(file);
+ try {
+ Document doc = XMLUtils.parse(ins);
+ XmlSchema schema = dataBinding.addSchemaDocument(serviceInfo,
+ schemas,
+ doc,
+ file);
+ schemaMap.put(file, schema);
+ return schema;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public void begin(MessagePartInfo part) {
+ LOG.finest(part.getName().toString());
+ // Check to see if the WSDL information has been filled in for us.
+ if (part.getTypeQName() != null || part.getElementQName() != null) {
+ checkForExistence(part);
+ return;
+ }
+
+ Class<?> clazz = part.getTypeClass();
+ if (clazz == null) {
+ return;
+ }
+
+ boolean isFromWrapper = part.getMessageInfo().getOperation().isUnwrapped();
+ if (isFromWrapper && clazz.isArray() && !Byte.TYPE.equals(clazz.getComponentType())) {
+ clazz = clazz.getComponentType();
+ }
+ try {
+ Field field = clazz.getField("type");
+ SchemaType st = (SchemaType)field.get(null);
+
+ SchemaTypeSystem sts = st.getTypeSystem();
+ XmlSchema schema = getSchema(sts, st.getSourceName());
+
+ if (st.getComponentType() == SchemaType.ELEMENT) {
+ XmlSchemaElement sct = schema.getElementByName(st.getName());
+ part.setXmlSchema(sct);
+ part.setElement(true);
+ } else {
+ XmlSchemaType sct = schema.getTypeByName(st.getName());
+ part.setTypeQName(st.getName());
+ part.setXmlSchema(sct);
+ part.setElement(false);
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void checkForExistence(MessagePartInfo part) {
+ QName qn = part.getElementQName();
+ if (qn != null) {
+ XmlSchemaElement el = schemas.getElementByQName(qn);
+ if (el == null) {
+ Class<?> clazz = part.getTypeClass();
+ if (clazz == null) {
+ return;
+ }
+
+ boolean isFromWrapper = part.getMessageInfo().getOperation().isUnwrapped();
+ if (isFromWrapper && clazz.isArray() && !Byte.TYPE.equals(clazz.getComponentType())) {
+ clazz = clazz.getComponentType();
+ }
+
+ //FIXME - find and set the part.setXmlSchema(....) info
+ }
+ }
+ }
+
+}
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/AbstractXmlBeansTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/AbstractXmlBeansTest.java?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/AbstractXmlBeansTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/AbstractXmlBeansTest.java Thu Nov 8 10:30:36 2007
@@ -0,0 +1,201 @@
+/**
+ * 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.xmlbeans;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.soap.SoapBindingFactory;
+import org.apache.cxf.binding.soap.SoapTransportFactory;
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.test.AbstractCXFTest;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
+import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
+import org.apache.cxf.wsdl11.WSDLManagerImpl;
+import org.junit.Before;
+
+public abstract class AbstractXmlBeansTest extends AbstractCXFTest {
+ protected LocalTransportFactory localTransport;
+
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUpBus();
+
+ SoapBindingFactory bindingFactory = new SoapBindingFactory();
+
+ bus.getExtension(BindingFactoryManager.class)
+ .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
+
+ DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+
+ SoapTransportFactory soapDF = new SoapTransportFactory();
+ soapDF.setBus(bus);
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
+ dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", soapDF);
+
+ localTransport = new LocalTransportFactory();
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
+ dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
+ dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", localTransport);
+ dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", localTransport);
+
+ ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
+ extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
+ extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
+ extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
+ extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/", localTransport);
+
+ bus.setExtension(new WSDLManagerImpl(), WSDLManager.class);
+
+
+ addNamespace("wsdl", SOAPConstants.WSDL11_NS);
+ addNamespace("wsdlsoap", SOAPConstants.WSDL11_SOAP_NS);
+ addNamespace("xsd", SOAPConstants.XSD);
+
+
+ }
+
+ @Override
+ protected Bus createBus() throws BusException {
+ ExtensionManagerBus bus = new ExtensionManagerBus();
+ BusFactory.setDefaultBus(bus);
+ return bus;
+ }
+
+ protected Node invoke(String service, String message) throws Exception {
+ return invoke("local://" + service, LocalTransportFactory.TRANSPORT_ID, message);
+ }
+
+ public Server createService(Class serviceClass, QName name) {
+ return createService(serviceClass, null, name);
+ }
+
+ public Server createService(Class serviceClass, Object serviceBean, QName name) {
+ return createService(serviceClass, serviceBean, serviceClass.getSimpleName(), name);
+ }
+
+ protected Server createService(Class serviceClass, QName name, XmlBeansDataBinding binding) {
+ return createService(serviceClass, serviceClass.getSimpleName(), name, binding);
+ }
+
+ protected Server createService(Class serviceClass,
+ String address, QName name,
+ XmlBeansDataBinding binding) {
+ ServerFactoryBean sf = createServiceFactory(serviceClass, null, address, name, binding);
+ return sf.create();
+ }
+
+ public Server createService(Class serviceClass,
+ Object serviceBean,
+ String address,
+ QName name) {
+ ServerFactoryBean sf = createServiceFactory(serviceClass, serviceBean, address, name, null);
+ return sf.create();
+ }
+
+ protected ServerFactoryBean createServiceFactory(Class serviceClass,
+ Object serviceBean,
+ String address,
+ QName name,
+ XmlBeansDataBinding binding) {
+ ServerFactoryBean sf = new ServerFactoryBean();
+ sf.setServiceClass(serviceClass);
+ if (serviceBean != null) {
+ sf.setServiceBean(serviceBean);
+ }
+ sf.getServiceFactory().setServiceName(name);
+ sf.setAddress("local://" + address);
+ setupXmlBeans(sf, binding);
+ return sf;
+ }
+ protected void setupXmlBeans(AbstractWSDLBasedEndpointFactory sf) {
+ setupXmlBeans(sf, null);
+ }
+ protected void setupXmlBeans(AbstractWSDLBasedEndpointFactory sf, XmlBeansDataBinding binding) {
+ if (binding == null) {
+ binding = new XmlBeansDataBinding();
+ }
+ sf.getServiceFactory().setDataBinding(binding);
+ }
+
+ protected Collection<Document> getWSDLDocuments(String string) throws WSDLException {
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+
+ Collection<Document> docs = new ArrayList<Document>();
+ Definition definition = getWSDLDefinition(string);
+ if (definition == null) {
+ return null;
+ }
+ docs.add(writer.getDocument(definition));
+
+ for (Import wsdlImport : WSDLDefinitionBuilder.getImports(definition)) {
+ docs.add(writer.getDocument(wsdlImport.getDefinition()));
+ }
+ return docs;
+ }
+
+ protected Definition getWSDLDefinition(String string) throws WSDLException {
+ ServerRegistry svrMan = getBus().getExtension(ServerRegistry.class);
+ for (Server s : svrMan.getServers()) {
+ Service svc = s.getEndpoint().getService();
+ if (svc.getName().getLocalPart().equals(string)) {
+ ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, svc.getServiceInfos());
+ return builder.build();
+ }
+ }
+ return null;
+
+ }
+
+ protected Document getWSDLDocument(String string) throws WSDLException {
+ Definition definition = getWSDLDefinition(string);
+ if (definition == null) {
+ return null;
+ }
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+ return writer.getDocument(definition);
+ }
+}
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/AbstractXmlBeansTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/AbstractXmlBeansTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/BasicTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/BasicTest.java?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/BasicTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/BasicTest.java Thu Nov 8 10:30:36 2007
@@ -0,0 +1,61 @@
+/**
+ * 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.xmlbeans.basic;
+
+
+import org.w3c.dom.Node;
+
+import org.apache.cxf.xmlbeans.AbstractXmlBeansTest;
+import org.junit.Before;
+import org.junit.Test;
+
+public class BasicTest extends AbstractXmlBeansTest {
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ createService(TestService.class, null, "TestService", null);
+ }
+
+ @Test
+ public void testBasicInvoke() throws Exception {
+ Node response = invoke("TestService", "bean11.xml");
+ addNamespace("ns1", "http://basic.xmlbeans.cxf.apache.org/");
+ assertValid("/s:Envelope/s:Body/ns1:echoAddressResponse", response);
+ assertValid("//ns1:echoAddressResponse/ns1:return", response);
+ assertValid("//ns1:echoAddressResponse/ns1:return/country", response);
+ assertValid("//ns1:echoAddressResponse/ns1:return/country[text()='Mars']",
+ response);
+ }
+
+ @Test
+ public void testWSDL() throws Exception {
+ Node doc = getWSDLDocument("TestService");
+ assertValid("/wsdl:definitions/wsdl:types/xsd:schema"
+ + "[@targetNamespace='http://cxf.apache.org/databinding/xmlbeans/test']",
+ doc);
+
+ assertValid("/wsdl:definitions/wsdl:types/xsd:schema"
+ + "[@targetNamespace='http://cxf.apache.org/databinding/xmlbeans/test']"
+ + "/xsd:complexType[@name='Address']",
+ doc);
+ }
+
+}
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/BasicTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/BasicTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/TestService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/TestService.java?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/TestService.java (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/TestService.java Thu Nov 8 10:30:36 2007
@@ -0,0 +1,42 @@
+/**
+ * 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.xmlbeans.basic;
+
+import org.apache.cxf.databinding.xmlbeans.test.Address;
+
+
+/**
+ *
+ */
+public class TestService {
+
+ public Address echoAddress(Address ad) {
+
+ Address ret = Address.Factory.newInstance();
+ ret.setAddressLine1(ad.getAddressLine1());
+ ret.setAddressLine2(ad.getAddressLine2());
+ ret.setCity(ad.getCity());
+ ret.setCountry(ad.getCountry());
+ ret.setZIPPostalCode(ad.getZIPPostalCode());
+ ret.setStateProvinceRegion(ad.getStateProvinceRegion());
+ return ret;
+ }
+
+}
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/TestService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/TestService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml Thu Nov 8 10:30:36 2007
@@ -0,0 +1,15 @@
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
+ <env:Header/>
+ <env:Body>
+ <ns1:echoAddress xmlns:ns1="http://basic.xmlbeans.cxf.apache.org/">
+ <ns1:ad>
+ <addressLine1>30 Foo Drive</addressLine1>
+ <addressLine2></addressLine2>
+ <city>Bar</city>
+ <stateProvinceRegion>SN</stateProvinceRegion>
+ <ZIPPostalCode>12345</ZIPPostalCode>
+ <country>Mars</country>
+ </ns1:ad>
+ </ns1:echoAddress>
+ </env:Body>
+</env:Envelope>
\ No newline at end of file
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/basic/bean11.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/XmlBeanTest.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/XmlBeanTest.xsd?rev=593243&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/XmlBeanTest.xsd (added)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/XmlBeanTest.xsd Thu Nov 8 10:30:36 2007
@@ -0,0 +1,60 @@
+<?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.
+-->
+<!--XSD file template-->
+<schema targetNamespace="http://cxf.apache.org/databinding/xmlbeans/test"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://cxf.apache.org/databinding/xmlbeans/test">
+ <complexType name="Address">
+ <sequence>
+ <element name="addressLine1" type="string"/>
+ <element name="addressLine2" nillable="true" type="string"/>
+ <element name="city" type="string"/>
+ <element name="stateProvinceRegion" type="string"/>
+ <element name="ZIPPostalCode" nillable="true" type="string"/>
+ <element name="country" type="string"/>
+ </sequence>
+ </complexType>
+ <complexType name="Person">
+ <sequence>
+ <element name="firstName" type="string"/>
+ <element name="lastName" type="string"/>
+ <element name="email" nillable="true" type="string"/>
+ <element name="contactPhoneNumber" nillable="true" type="string"/>
+ <element name="address" nillable="true" type="tns:Address"/>
+ </sequence>
+ </complexType>
+ <complexType name="Customer">
+ <complexContent>
+ <extension base="tns:Person">
+ <sequence>
+ <element name="customerNumber" type="string"/>
+ <element name="supportLevel" type="tns:SupportLevel"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ <simpleType name="SupportLevel">
+ <restriction base="string">
+ <enumeration value="Silver"/>
+ <enumeration value="Bronze"/>
+ <enumeration value="Gold"/>
+ </restriction>
+ </simpleType>
+</schema>
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/XmlBeanTest.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/XmlBeanTest.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/rt/databinding/xmlbeans/src/test/xsd/XmlBeanTest.xsd
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=593243&r1=593242&r2=593243&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Thu Nov 8 10:30:36 2007
@@ -706,6 +706,9 @@
if (!oldEl.getQName().equals(qname)) {
el.setSchemaTypeName(oldEl.getSchemaTypeName());
el.setSchemaType(oldEl.getSchemaType());
+ if (oldEl.getSchemaTypeName() != null) {
+ addImport(schema, oldEl.getSchemaTypeName().getNamespaceURI());
+ }
}
mpi.setXmlSchema(el);
mpi.setElementQName(qname);
@@ -713,14 +716,7 @@
continue;
} else {
el.setSchemaTypeName(mpi.getTypeQName());
- String ns = mpi.getTypeQName().getNamespaceURI();
- if (!ns.equals(schema.getTargetNamespace()) && !ns.equals(WSDLConstants.NS_SCHEMA_XSD)) {
- XmlSchemaImport is = new XmlSchemaImport();
- is.setNamespace(ns);
- if (!isExistImport(schema, ns)) {
- schema.getItems().add(is);
- }
- }
+ addImport(schema, mpi.getTypeQName().getNamespaceURI());
}
schemaInfo.setSchema(schema);
@@ -731,6 +727,16 @@
}
}
+ private void addImport(XmlSchema schema, String ns) {
+ if (!ns.equals(schema.getTargetNamespace())
+ && !ns.equals(WSDLConstants.NS_SCHEMA_XSD)
+ && !isExistImport(schema, ns)) {
+
+ XmlSchemaImport is = new XmlSchemaImport();
+ is.setNamespace(ns);
+ schema.getItems().add(is);
+ }
+ }
private boolean isExistImport(XmlSchema schema, String ns) {
boolean isExist = false;
@@ -782,7 +788,7 @@
if (!isAnonymousWrapperTypes()) {
ct.setName(wrapperName.getLocalPart());
- el.setSchemaTypeName(wrapperName);
+ el.setSchemaTypeName(wrapperName);
schema.addType(ct);
schema.getItems().add(ct);
}
@@ -797,9 +803,14 @@
el.setName(mpi.getName().getLocalPart());
el.setQName(mpi.getName());
if (mpi.isElement()) {
+ addImport(schema, mpi.getElementQName().getNamespaceURI());
el.setRefName(mpi.getElementQName());
} else {
- el.setSchemaTypeName(mpi.getTypeQName());
+ if (mpi.getTypeQName() != null) {
+ el.setSchemaTypeName(mpi.getTypeQName());
+ addImport(schema, mpi.getTypeQName().getNamespaceURI());
+ }
+
el.setSchemaType((XmlSchemaType)mpi.getXmlSchema());
if (schema.getElementFormDefault().getValue().equals(XmlSchemaForm.UNQUALIFIED)) {
mpi.setConcreteName(new QName(null, mpi.getName().getLocalPart()));
Modified: incubator/cxf/trunk/rt/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/pom.xml?rev=593243&r1=593242&r2=593243&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/pom.xml (original)
+++ incubator/cxf/trunk/rt/pom.xml Thu Nov 8 10:30:36 2007
@@ -36,6 +36,7 @@
<module>transports/local</module>
<module>testsupport</module>
<module>databinding/jaxb</module>
+ <module>databinding/xmlbeans</module>
<module>databinding/aegis</module>
<module>bindings</module>
<module>frontend/simple</module>